]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Use uv_available_parallelism() if available
authorOndřej Surý <ondrej@isc.org>
Thu, 19 Sep 2024 15:58:19 +0000 (17:58 +0200)
committerOndřej Surý <ondrej@isc.org>
Sat, 21 Sep 2024 10:38:33 +0000 (12:38 +0200)
Instead of cooking up our own code for getting the number of available
CPUs for named to use, make use of uv_available_parallelism() from
libuv >= 1.44.0.

lib/isc/os.c

index fced991903109ec32bbb985ca806710baa6781bd..97b5cac02467aa408999632dc1a4448b33a42ac0 100644 (file)
@@ -17,6 +17,7 @@
 #include <isc/os.h>
 #include <isc/types.h>
 #include <isc/util.h>
+#include <isc/uv.h>
 
 #include "os_p.h"
 
@@ -24,6 +25,20 @@ static unsigned int isc__os_ncpus = 0;
 static unsigned long isc__os_cacheline = ISC_OS_CACHELINE_SIZE;
 static mode_t isc__os_umask = 0;
 
+/*
+ * The affinity support for non-Linux is in the review in the upstream
+ * yet, but will be included in the upcoming version of libuv.
+ */
+#if (UV_VERSION_HEX >= UV_VERSION(1, 44, 0) && defined(__linux__)) || \
+       UV_VERSION_HEX > UV_VERSION(1, 48, 0)
+
+static void
+ncpus_initialize(void) {
+       isc__os_ncpus = uv_available_parallelism();
+}
+
+#else /* UV_VERSION_HEX >= UV_VERSION(1, 44, 0) */
+
 #ifdef HAVE_SYSCONF
 
 #include <unistd.h>
@@ -151,6 +166,8 @@ ncpus_initialize(void) {
        }
 }
 
+#endif /* UV_VERSION_HEX >= UV_VERSION(1, 38, 0) */
+
 static void
 umask_initialize(void) {
        isc__os_umask = umask(0);