From: Witold Krecicki Date: Fri, 26 Oct 2018 12:41:48 +0000 (+0200) Subject: FreeBSD fixes - proper affinity setting, don't use SO_REUSEPORT X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f4029bd2eea1e50eaba085fdb3d65fe1070b9ec;p=thirdparty%2Fbind9.git FreeBSD fixes - proper affinity setting, don't use SO_REUSEPORT --- diff --git a/lib/isc/pthreads/thread.c b/lib/isc/pthreads/thread.c index 94801d50856..4795b5ba08a 100644 --- a/lib/isc/pthreads/thread.c +++ b/lib/isc/pthreads/thread.c @@ -110,7 +110,7 @@ isc_thread_setaffinity(int cpu) { CPU_ZERO(&cpuset); CPU_SET(cpu, &cpuset); if (cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, -1, - &cpuset, sizeof(cpuset)) != 0) { + sizeof(cpuset), &cpuset) != 0) { return (ISC_R_FAILURE); } #elif defined(HAVE_PTHREAD_SETAFFINITY_NP) diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c index 163ddac1ed7..6bad341a2e0 100644 --- a/lib/isc/unix/socket.c +++ b/lib/isc/unix/socket.c @@ -3273,8 +3273,6 @@ process_fds(isc__socketthread_t *thread, struct kevent *events, bool readable, writable; bool done = false; bool have_ctlevent = false; - INSIST(thread->threadid == 0); - if (nevents == thread->nevents) { /* * This is not an error, but something unexpected. If this @@ -5448,7 +5446,12 @@ static bool hasreuseport = false; static void init_hasreuseport() { -#ifdef SO_REUSEPORT +/* + * SO_REUSEPORT works very differently on *BSD and on Linux (because why not). + * We only want to use it on Linux, if it's available. On BSD we want to dup() + * sockets instead of re-binding them. + */ +#if defined(SO_REUSEPORT) && defined(__linux__) int sock, yes = 1; sock = socket(AF_INET, SOCK_DGRAM, 0); if (sock < 0) {