ws2_32: WSACleanup cleans up open sockets (OSX only)

Ken Thomases ken at codeweavers.com
Wed Aug 26 14:50:22 CDT 2015


On Aug 25, 2015, at 9:09 AM, Henri Verbeet <hverbeet at gmail.com> wrote:

> On 25 August 2015 at 06:46, Ken Thomases <ken at codeweavers.com> wrote:
>>> On Aug 24, 2015, at 10:49 PM, Matt Durgavich <mattdurgavich at gmail.com> wrote:
>>> +#define CACHE_SIZE  256
>>> +#define CACHE_DEPTH 16
>>> +static SOCKET socket_cache[CACHE_SIZE][CACHE_DEPTH];
>>> +
>>> +/* Cache support */
>>> +static void add_to_cache(SOCKET s);
>>> +static BOOL remove_from_cache(SOCKET s);
>>> +static BOOL socket_in_cache(SOCKET s);
>> I'm not sure this is a "cache", per se. It's a hash table, but naming issues are fairly minor.
>> 
> 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.  However, that may be premature optimization.  Whether it's worth using a hash table for that depends on how many sockets a process is likely to open and how frequently it does an operation that needs to check the list. For example, the patch adds a check of the list in WS2_sendto().  I'm not sure why it adds that check (and only to that specific function), but you wouldn't want to slow that down too much.

-Ken




More information about the wine-devel mailing list