Commit 38c5469
committed
Only close epoller FD at most once.
Previously, multiple calls to epoller.Close() could result in unix.Close being
called on the same FD value multiple times. This made it easy for consumers to
create race conditions where calls to Close after the first one were closing
unrelated FDs in the process that happened to use the same value of the epoller
FD.
This change uses sync.Once to ensure that unix.Close is only called once, with
subsequent calls to Close returning "file already closed" instead.
Signed-off-by: Erik Sipsma <[email protected]>1 parent 02ecf6a commit 38c5469
2 files changed
Lines changed: 14 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| |||
151 | 152 | | |
152 | 153 | | |
153 | 154 | | |
154 | | - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
155 | 160 | | |
156 | 161 | | |
157 | 162 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
88 | 96 | | |
0 commit comments