From 91e3ead85eb81c3f8aabb8a193e3cc952755d87a Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Sat, 10 Jan 2009 14:37:45 +0000 Subject: [PATCH] Improve the hashsocket function. svn:r989 --- evmap.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/evmap.c b/evmap.c index d74da260..65951493 100644 --- a/evmap.c +++ b/evmap.c @@ -91,7 +91,12 @@ struct event_map_entry { static inline unsigned hashsocket(struct event_map_entry *e) { - return (unsigned) e->fd; + /* On win32, in practice, the low 2-3 bits of a SOCKET seem not to + * matter. Our hashtable implementation really likes low-order bits, + * though, so let's do the rotate-and-add trick. */ + unsigned h = (unsigned) e->fd; + h += (h >> 2) | (h << 30); + return h; } static inline int -- 2.40.0