Commit 5d1b48d
committed
console_linux: Fix race: lock Cond before Signal.
Possible race:
Thread1: Thread2:
line 178: Read() -> EAGAIN ...
<reschedule> line 110: EpollWait()
... line 124: signalRead()
... ...
line 191: Wait() ...
line 110: EpollWait()
Thread2 (epoll) sends signalRead() (via sync.Cond) but Thread1 is not waiting
yet. Then it starts to wait, but no more signals will arrive (because Thread2
is sleeping in EpollWait() on edge-triggered epoll.
To prevent this race one should held Lock when sending signalRead().
The same situation goes with Write loop.
Bug was reported to docker: docker/for-linux#353
Signed-off-by: Alexander Gerasiov <[email protected]>1 parent 9a57d21 commit 5d1b48d
1 file changed
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
| 265 | + | |
265 | 266 | | |
| 267 | + | |
266 | 268 | | |
267 | 269 | | |
268 | 270 | | |
269 | 271 | | |
| 272 | + | |
270 | 273 | | |
| 274 | + | |
271 | 275 | | |
0 commit comments