]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Remove .listener member of controlistener struct
authorOndřej Surý <ondrej@sury.org>
Mon, 21 Sep 2020 08:16:36 +0000 (10:16 +0200)
committerOndřej Surý <ondrej@sury.org>
Mon, 21 Sep 2020 08:21:04 +0000 (10:21 +0200)
In the new netmgr code, the .listener member was mostly functionally
only duplicating the .exiting member and was unneeded.  This also
resolves following ThreadSanitizer (harmless) warning:

    WARNING: ThreadSanitizer: data race
      Write of size 1 at 0x000000000001 by thread T1:
#0 control_senddone bin/named/controlconf.c:257:22
#1 tcp_send_cb lib/isc/netmgr/tcp.c:1027:2
#2 uv__write_callbacks /home/ondrej/Projects/tsan/libuv/src/unix/stream.c:953:7
#3 uv__stream_io /home/ondrej/Projects/tsan/libuv/src/unix/stream.c:1330:5
#4 uv__run_pending /home/ondrej/Projects/tsan/libuv/src/unix/core.c:812:5
#5 uv_run /home/ondrej/Projects/tsan/libuv/src/unix/core.c:377:19
#6 nm_thread lib/isc/netmgr/netmgr.c:500:11

      Previous write of size 1 at 0x000000000001 by thread T2:
#0 control_senddone bin/named/controlconf.c:257:22
#1 tcp_send_cb lib/isc/netmgr/tcp.c:1027:2
#2 uv__write_callbacks /home/ondrej/Projects/tsan/libuv/src/unix/stream.c:953:7
#3 uv__stream_io /home/ondrej/Projects/tsan/libuv/src/unix/stream.c:1330:5
#4 uv__run_pending /home/ondrej/Projects/tsan/libuv/src/unix/core.c:812:5
#5 uv_run /home/ondrej/Projects/tsan/libuv/src/unix/core.c:377:19
#6 nm_thread lib/isc/netmgr/netmgr.c:500:11

      Location is heap block of size 265 at 0x000000000009 allocated by thread T3:
#0 malloc <null>
#1 default_memalloc lib/isc/mem.c:713:8
#2 mem_get lib/isc/mem.c:622:8
#3 isc___mem_get lib/isc/mem.c:1044:9
#4 isc__mem_get lib/isc/mem.c:2432:10
#5 add_listener bin/named/controlconf.c:1133:13
#6 named_controls_configure bin/named/controlconf.c:1331:6
#7 load_configuration bin/named/server.c:9133:2
#8 run_server bin/named/server.c:9771:2
#9 dispatch lib/isc/task.c:1152:7
#10 run lib/isc/task.c:1344:2

      Thread T2 (running) created by main thread at:
#0 pthread_create <null>
#1 isc_thread_create lib/isc/pthreads/thread.c:73:8
#2 isc_nm_start lib/isc/netmgr/netmgr.c:223:3
#3 create_managers bin/named/main.c:909:15
#4 setup bin/named/main.c:1223:11
#5 main bin/named/main.c:1523:2

      Thread T2 (running) created by main thread at:
#0 pthread_create <null>
#1 isc_thread_create lib/isc/pthreads/thread.c:73:8
#2 isc_nm_start lib/isc/netmgr/netmgr.c:223:3
#3 create_managers bin/named/main.c:909:15
#4 setup bin/named/main.c:1223:11
#5 main bin/named/main.c:1523:2

      Thread T3 (running) created by main thread at:
#0 pthread_create <null>
#1 isc_thread_create lib/isc/pthreads/thread.c:73:8
#2 isc_taskmgr_create lib/isc/task.c:1434:3
#3 create_managers bin/named/main.c:915:11
#4 setup bin/named/main.c:1223:11
#5 main bin/named/main.c:1523:2

    SUMMARY: ThreadSanitizer: data race bin/named/controlconf.c:257:22 in control_senddone

bin/named/controlconf.c

index 93e1d82065cfb383ef0d2786ec836a637c04c596..0b38b51a7fbef22fb64607e28c94c30b3115564d 100644 (file)
@@ -94,7 +94,6 @@ struct controllistener {
        isc_sockaddr_t address;
        isc_nmsocket_t *sock;
        dns_acl_t *acl;
-       bool listening;
        bool exiting;
        controlkeylist_t keys;
        controlconnectionlist_t connections;
@@ -144,7 +143,6 @@ free_controlkeylist(controlkeylist_t *keylist, isc_mem_t *mctx) {
 static void
 free_listener(controllistener_t *listener) {
        INSIST(listener->exiting);
-       INSIST(!listener->listening);
        INSIST(ISC_LIST_EMPTY(listener->connections));
 
        if (listener->sock != NULL) {
@@ -162,9 +160,7 @@ free_listener(controllistener_t *listener) {
 
 static void
 maybe_free_listener(controllistener_t *listener) {
-       if (listener->exiting && !listener->listening &&
-           ISC_LIST_EMPTY(listener->connections))
-       {
+       if (listener->exiting && ISC_LIST_EMPTY(listener->connections)) {
                free_listener(listener);
        }
 }
@@ -188,7 +184,6 @@ shutdown_listener(controllistener_t *listener) {
                }
 #endif
                listener->exiting = true;
-               listener->listening = false;
        }
 
        isc_nm_stoplistening(listener->sock);
@@ -256,8 +251,6 @@ control_senddone(isc_nmhandle_t *handle, isc_result_t result, void *arg) {
                return;
        }
 
-       listener->listening = true;
-
        return;
 
 cleanup_sendhandle:
@@ -660,8 +653,6 @@ control_newconn(isc_nmhandle_t *handle, isc_result_t result, void *arg) {
        controllistener_t *listener = arg;
        isc_sockaddr_t peeraddr;
 
-       listener->listening = false;
-
        if (result != ISC_R_SUCCESS) {
                if (result == ISC_R_CANCELED) {
                        shutdown_listener(listener);
@@ -1204,7 +1195,6 @@ add_listener(named_controls_t *cp, controllistener_t **listenerp,
                               control_newconn, listener,
                               sizeof(controlconnection_t), 5, NULL,
                               &listener->sock));
-       listener->listening = true;
 #if 0
        /* XXX: no unix socket support yet */
        if (type == isc_socktype_unix) {