Commit fe3ae8e
committed
event: handle socket events more precisely
This adjusts the socket event to correct a potential spurious wakeup
which can incorrectly mark the socket as closed.
When working with a `SOCK_STREAM` socket, `FIONREAD` returns the total
amount of data that can be read in a single receive operation.
Normally, this is the same amount of data queued on the socket, but this
is not guaranteed as a data-stream is byte-oriented. Additionally, a
read on a separate thread may have drained the data between the event
trigger and the ioctl to read the available bytes. Only wake up the
handler if there are bytes to read.
In order to differentiate between the trigger for a close event and a
read-event, we explicitly check the close and the read or write event.
This allows waking the handlers one last time after a socket is closed.1 parent 35f5c96 commit fe3ae8e
1 file changed
+5
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
359 | 359 | | |
360 | 360 | | |
361 | 361 | | |
362 | | - | |
363 | | - | |
364 | 362 | | |
365 | 363 | | |
366 | 364 | | |
367 | | - | |
| 365 | + | |
| 366 | + | |
368 | 367 | | |
369 | 368 | | |
370 | 369 | | |
371 | 370 | | |
372 | 371 | | |
373 | 372 | | |
374 | 373 | | |
375 | | - | |
| 374 | + | |
376 | 375 | | |
377 | | - | |
| 376 | + | |
| 377 | + | |
378 | 378 | | |
379 | 379 | | |
380 | 380 | | |
| |||
0 commit comments