https://bugs.winehq.org/show_bug.cgi?id=38399
--- Comment #6 from Bruno Jesus 00cpxxx@gmail.com --- (In reply to Sebastian Lackner from comment #4)
When I understand the problem correctly, then using a complicated approach with get_sock_fd() and release_sock_fd() is the only way to do it properly with the current design. If ws2_32 code gets moved to ntdll at some point in the future then there might be ways to do it easier.
To use the patch approach I believe your lock free cache patch would be good, to reduce performance impact. I have to test this with much larger select sets to check.
The main problem is how to tell if POLLHUP was a misc socket problem, socket closed in other thread or socket didn't connect to server. Windows select call reacts differently to these 3 situations and they are all covered in the tests now. If there was a wine_server_handle_exists( SOCKET2HANDLE(s) ) it could at least eliminate the need for the dup call.