[EventEngine] Fix WinSocket/IOCP notification race (#34497)
It was possible for threads that call `WinSocket::NotifyOnRead` and `WinSocket::NotifyOnWrite` to race against IOCP poller threads, causing poller events to be missed. In the most common usage, in some thread (E), the Endpoint would make an async (overlapped) read or write using `WSARecv` or `WSASend` respectively, then use the socket's `NotifyOn*` methods to have callbacks executed when data was ready. If data was already available, those callbacks would be scheduled for execution immediately. Meanwhile, if overlapped events came in for some socket, some IOCP poller thread (P) would inform the socket that data was ready, and if notification callbacks were already present, they would be scheduled for execution immediately. It was possible for thread (E) to see no data available, and thread (P) to not see any notification callbacks registered. This resulted in registered callbacks that would never be called, for data that had already been received.pull/34607/head
parent
3ebdb07203
commit
2f5449d36d
3 changed files with 31 additions and 22 deletions
Loading…
Reference in new issue