Hi, in an attempt to fix bugs 18670 and 26031 I would like to try implementing WSACleanup more properly. My limited knowledge in the interactions between the ws2_32 dll and wine server makes me think this is easy.
The idea is to add the created socket in WSASocketW in a list and remove it from the list when closesocket is called. When the last WSACleanup is called it would iterate through the socket list and destroy the remaining sockets.
When WSASocketW is called it calls the server to create the socket, when closesocket is called the server is also called and the function sock_destroy takes care of shutting down the socket.
Currently I'm thinking about doing this in the dll side because the server is not aware of WSACleanup, but maybe it should because it needs to avoid calling any async operation completion.
My questions are: 1) When I open 2 programs that use ws2_32 dll the global variables memory is not shared, right? Otherwise the WSAStartup/Cleanup count could be messed up if one application didn't call the Cleanup function. I hope this true so the socket list would not have to take care of different processes id.
I understand that one application can have multiple threads and that's what the struct per_thread_data is about, but I hope the dll is not shared among different processes.
2) Is this a reasonable approach? If yes, is there any example of a critical protected list (add, iterate, remove items) that I could use?
Best wishes, Bruno