]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
simplify nchildren count in isc_nm_listenudp
authorColin Vidal <colin@isc.org>
Tue, 16 Sep 2025 12:15:07 +0000 (14:15 +0200)
committerColin Vidal <colin@isc.org>
Tue, 16 Sep 2025 12:22:15 +0000 (14:22 +0200)
Slight simplification of the logic to define .nchildren listening UDP
socket.

lib/isc/netmgr/udp.c

index ce1f4bb638651a8eac9b130427261041b6a4fbfd..bb3cb67045a80080941f8e12757a9c1e27f7de80 100644 (file)
@@ -216,17 +216,16 @@ isc_nm_listenudp(uint32_t workers, isc_sockaddr_t *iface, isc_nm_recv_cb_t cb,
                return ISC_R_SHUTTINGDOWN;
        }
 
-       if (workers == 0) {
-               workers = isc__netmgr->nloops;
-       }
-       REQUIRE(workers <= isc__netmgr->nloops);
-
        sock = isc_mempool_get(worker->nmsocket_pool);
        isc__nmsocket_init(sock, worker, isc_nm_udplistener, iface, NULL);
 
-       sock->nchildren = (workers == ISC_NM_LISTEN_ALL)
-                                 ? (uint32_t)isc__netmgr->nloops
-                                 : workers;
+       if (workers == ISC_NM_LISTEN_ALL) {
+               sock->nchildren = (uint32_t)isc__netmgr->nloops;
+       } else {
+               sock->nchildren = workers;
+       }
+       REQUIRE(sock->nchildren <= isc__netmgr->nloops);
+
        sock->children = isc_mem_cget(worker->mctx, sock->nchildren,
                                      sizeof(sock->children[0]));