On 12/6/21 19:30, Dongwan Kim wrote:
Calling try_recv could make messages misordered.
Suppose that a server program calls a overlapped WSARecv and its operation is pending. Another program sends a message and wineserver is busy. The server program calls another overlapped WSARecv and it intercepts the message for the pending WSARecv.
The problem already had been discussed here https://www.winehq.org/pipermail/wine-devel/2021-May/186612.html
To avoid this situation, this kind of approach can be applied.
The server program needs to know if there are pending asyncs before calling try_recv. Wineserver notifies it whenever invoking APC_ASYNC_IO. Then, the server program updates it and check it before calling try_recv.
This is broken for a few reasons, but the main one is that socket handles are cross-process, which is the main reason that the server is involved in the first place.
As I asked the last time a patch like this was submitted [1], it would firstly be nice to know what application needs this, and second, it would be nice to have a test case (ideally in-tree, but if necessary out-of-tree) to validate that this guarantee holds.
[1] https://www.winehq.org/pipermail/wine-devel/2021-May/186848.html