The attached patch implements a socket queue in the DLL side and implements WSACleanup. For now the socket list does not have any parameter but my target is to add more stuff to it and reduce the server calls. Any comments are appreciated.
Best wishes, Bruno
On Sun, Dec 29, 2013 at 4:21 PM, David Quintana (gigaherz) gigaherz@gmail.com wrote:
I have no knowledge about windows sockets, but DLLs are not shared across processes. If a DLL wants shared memory it has to map it explicitly, like everything else. On the other hand threads do share all memory, and windows provides thread-local storage to allow thread-specific variables.
On 29 Dec 2013 19:15, "Bruno Jesus" 00cpxxx@gmail.com wrote:
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:
- 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.
- 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