Bruno wrote a patch a while back that tracked sockets in a linked list, and the feedback there was to use a hashing scheme similar to how files are handled since sockets, like files, can be opened and closed rapidly.
Chip made this point re ws2_32 tracking sockets:
"The second option I gave might be preferable, because e.g. someone could DuplicateHandle() a winsock handle into another process, and WSACleanup() might not close it when it runs. (Someone should write a test for that.)”
For the server side approach, I’d need to map the fd back to a handle that can be closed. I imagine a server call is somewhat pricey, but WSACleanup shouldn’t be called often. Is there more subtly to the problem than that?
Can we get a consensus here as to the right approach? I don’t want to polish a patch that is wrong-headed.
Thanks, -Matt
On Aug 26, 2015, at 4:59 PM, Henri Verbeet hverbeet@gmail.com wrote:
On 26 August 2015 at 21:50, Ken Thomases ken@codeweavers.com wrote:
On Aug 25, 2015, at 9:09 AM, Henri Verbeet hverbeet@gmail.com wrote:
If the idea is just to keep track of all the sockets you give out you want neither of those of course, but just something like a handle table or a list.
I think the intent was to make it efficient to find a given socket handle in the list.
You'd just lookup the handle in the table. Of course it would probably be much easier to just do it in the server, since it already keeps track of socket handles.