]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Mangle fdlocks a bit
authorWitold Kręcicki <wpk@isc.org>
Wed, 3 Oct 2018 22:11:52 +0000 (22:11 +0000)
committerWitold Kręcicki <wpk@isc.org>
Wed, 24 Oct 2018 07:10:20 +0000 (07:10 +0000)
lib/isc/unix/socket.c
lib/isc/win32/socket.c

index 6afa5d289693c6c0ff3244a9cb65864742094afa..6cc3eb744509209d5598f861f7d98160911ca44b 100644 (file)
@@ -185,10 +185,12 @@ typedef enum { poll_idle, poll_active, poll_checking } pollstate_t;
 #endif /* ISC_SOCKET_USE_POLLWATCH */
 
 /*%
- * Size of per-FD lock buckets.
+ * Per-FD lock buckets, we shuffle them around a bit as FDs come in herds.
  */
-#define FDLOCK_COUNT           1024
-#define FDLOCK_ID(fd)          ((fd) % FDLOCK_COUNT)
+#define FDLOCK_BITS            10
+#define FDLOCK_COUNT           (1<<FDLOCK_BITS)
+#define FDLOCK_ID(fd)          (((fd)%(FDLOCK_COUNT)>>(FDLOCK_BITS/2)) |\
+                                (((fd)<<(FDLOCK_BITS/2))%(FDLOCK_COUNT)))
 
 /*%
  * Maximum number of events communicated with the kernel.  There should normally
@@ -3858,7 +3860,7 @@ setup_thread(isc__socketthread_t *thread) {
        if (result != ISC_R_SUCCESS)
                manager->open_max = 64;
        manager->calls = 0;
-       manager->events = isc_mem_get(thread->manager->mctx, 
+       manager->events = isc_mem_get(thread->manager->mctx,
                                      sizeof(struct pollfd) *
                                      manager->nevents);
        if (manager->events == NULL)
@@ -5687,11 +5689,11 @@ init_hasreuseport() {
                close(sock);
                return;
        } else if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&yes,
-                       sizeof(yes)) < 0) {
+                      sizeof(yes)) < 0) {
                close(sock);
                return;
        } else if (setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, (void *)&yes,
-                       sizeof(yes)) < 0) {
+                      sizeof(yes)) < 0) {
                close(sock);
                return;
        }
index a64f11d9ebe021babbae862f0c9fd25af79cc8a8..b61f2d7b19a09654e3199fe6fb30c9105169d633 100644 (file)
@@ -3943,7 +3943,7 @@ isc_socket_socketevent(isc_mem_t *mctx, void *sender,
 
 bool
 isc_socket_hasreuseport() {
-        return (false);
+       return (false);
 }
 
 #ifdef HAVE_LIBXML2