On Aug 25, 2015, at 9:09 AM, Henri Verbeet hverbeet@gmail.com wrote:
On 25 August 2015 at 06:46, Ken Thomases ken@codeweavers.com wrote:
On Aug 24, 2015, at 10:49 PM, Matt Durgavich mattdurgavich@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