]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
DROP: lots of printfs
authorEvan Hunt <each@isc.org>
Sun, 7 Jun 2020 23:20:41 +0000 (16:20 -0700)
committerWitold Kręcicki <wpk@isc.org>
Thu, 18 Jun 2020 08:04:09 +0000 (10:04 +0200)
doc/misc/options
lib/isc/netmgr/netmgr-int.h
lib/isc/netmgr/netmgr.c
lib/isc/netmgr/tcpdns.c

index ea9242ef671f21941401c55d2c67aa1d17da6efc..51614745454bf528f4981db2d12da167229040fe 100644 (file)
@@ -166,13 +166,16 @@ options {
         dnssec-secure-to-insecure <boolean>;
         dnssec-update-mode ( maintain | no-resign );
         dnssec-validation ( yes | no | auto );
-        dnstap { ( all | auth | client | forwarder | resolver | update ) [
-            ( query | response ) ]; ... };
-        dnstap-identity ( <quoted_string> | none | hostname );
-        dnstap-output ( file | unix ) <quoted_string> [ size ( unlimited |
-            <size> ) ] [ versions ( unlimited | <integer> ) ] [ suffix (
-            increment | timestamp ) ];
-        dnstap-version ( <quoted_string> | none );
+        dnstap { ( all | auth | client | forwarder |
+            resolver | update ) [ ( query | response ) ];
+            ... }; // not configured
+        dnstap-identity ( <quoted_string> | none |
+            hostname ); // not configured
+        dnstap-output ( file | unix ) <quoted_string> [
+            size ( unlimited | <size> ) ] [ versions (
+            unlimited | <integer> ) ] [ suffix ( increment
+            | timestamp ) ]; // not configured
+        dnstap-version ( <quoted_string> | none ); // not configured
         dscp <integer>;
         dual-stack-servers [ port <integer> ] { ( <quoted_string> [ port
             <integer> ] [ dscp <integer> ] | <ipv4_address> [ port
@@ -196,13 +199,13 @@ options {
         forward ( first | only );
         forwarders [ port <integer> ] [ dscp <integer> ] { ( <ipv4_address>
             | <ipv6_address> ) [ port <integer> ] [ dscp <integer> ]; ... };
-        fstrm-set-buffer-hint <integer>;
-        fstrm-set-flush-timeout <integer>;
-        fstrm-set-input-queue-size <integer>;
-        fstrm-set-output-notify-threshold <integer>;
-        fstrm-set-output-queue-model ( mpsc | spsc );
-        fstrm-set-output-queue-size <integer>;
-        fstrm-set-reopen-interval <duration>;
+        fstrm-set-buffer-hint <integer>; // not configured
+        fstrm-set-flush-timeout <integer>; // not configured
+        fstrm-set-input-queue-size <integer>; // not configured
+        fstrm-set-output-notify-threshold <integer>; // not configured
+        fstrm-set-output-queue-model ( mpsc | spsc ); // not configured
+        fstrm-set-output-queue-size <integer>; // not configured
+        fstrm-set-reopen-interval <duration>; // not configured
         geoip-directory ( <quoted_string> | none );
         geoip-use-ecs <boolean>; // obsolete
         glue-cache <boolean>;
@@ -547,8 +550,9 @@ view <string> [ <class> ] {
         dnssec-secure-to-insecure <boolean>;
         dnssec-update-mode ( maintain | no-resign );
         dnssec-validation ( yes | no | auto );
-        dnstap { ( all | auth | client | forwarder | resolver | update ) [
-            ( query | response ) ]; ... };
+        dnstap { ( all | auth | client | forwarder |
+            resolver | update ) [ ( query | response ) ];
+            ... }; // not configured
         dual-stack-servers [ port <integer> ] { ( <quoted_string> [ port
             <integer> ] [ dscp <integer> ] | <ipv4_address> [ port
             <integer> ] [ dscp <integer> ] | <ipv6_address> [ port
index d066198bd012f2c72a18545cad997e607674f960..9f26369715d92bd12fc10834859cc6c789c096f8 100644 (file)
@@ -804,3 +804,9 @@ isc__nm_decstats(isc_nm_t *mgr, isc_statscounter_t counterid);
 /*%<
  * Decrement socket-related statistics counters.
  */
+
+const char *
+isc__nm_socket_type(isc_nmsocket_type type);
+/*%<
+ * Returns socket type as a string for logging purposes.
+ */
index 1a4a82c831a102caaeefe10b49a7d456d3606c7c..e9e23a457faf91515d2e4fde7b04d9de400e770f 100644 (file)
@@ -129,6 +129,27 @@ async_cb(uv_async_t *handle);
 static void
 process_queue(isc__networker_t *worker, isc_queue_t *queue);
 
+const char *
+isc__nm_socket_type(isc_nmsocket_type type) {
+       switch(type) {
+       case isc_nm_udpsocket:
+               return("udpsocket");
+       case isc_nm_udplistener:
+               return("udplistener");
+       case isc_nm_tcpsocket:
+               return("tcpsocket");
+       case isc_nm_tcplistener:
+               return("tcplistener");
+       case isc_nm_tcpdnssocket:
+               return("tcpdnssocket");
+       case isc_nm_tcpdnslistener:
+               return("tcpdnslistener");
+       default:
+               INSIST(0);
+               ISC_UNREACHABLE();
+       }
+}
+
 int
 isc_nm_tid(void) {
        return (isc__nm_tid_v);
@@ -692,8 +713,10 @@ isc__nmsocket_attach(isc_nmsocket_t *sock, isc_nmsocket_t **target) {
 
        if (sock->parent != NULL) {
                INSIST(sock->parent->parent == NULL); /* sanity check */
+fprintf(stderr, "attach sock %p (%s) (%p) to %lu\n", sock, isc__nm_socket_type(sock->type), sock->parent, sock->parent->references+1);
                isc_refcount_increment0(&sock->parent->references);
        } else {
+fprintf(stderr, "attach sock %p (%s) to %lu\n", sock, isc__nm_socket_type(sock->type), sock->references+1);
                isc_refcount_increment0(&sock->references);
        }
 
@@ -740,6 +763,7 @@ nmsocket_cleanup(isc_nmsocket_t *sock, bool dofree) {
 
        if (sock->outerhandle != NULL) {
                isc_nmhandle_unref(sock->outerhandle);
+fprintf(stderr, "sock %p outerhandle %p, clearing?\n", sock, sock->outerhandle);
                sock->outerhandle = NULL;
        }
 
@@ -897,8 +921,10 @@ isc__nmsocket_detach(isc_nmsocket_t **sockp) {
         */
        if (sock->parent != NULL) {
                rsock = sock->parent;
+fprintf(stderr, "detach sock %p (%s) (%p) to %lu\n", sock, isc__nm_socket_type(sock->type), rsock, rsock->references-1);
                INSIST(rsock->parent == NULL); /* Sanity check */
        } else {
+fprintf(stderr, "detach sock %p (%s) to %lu\n", sock, isc__nm_socket_type(sock->type), sock->references-1);
                rsock = sock;
        }
 
@@ -928,6 +954,7 @@ isc__nmsocket_init(isc_nmsocket_t *sock, isc_nm_t *mgr, isc_nmsocket_type type,
        REQUIRE(iface != NULL);
 
        family = iface->addr.type.sa.sa_family;
+fprintf(stderr, "init sock %p (%s)\n", sock, isc__nm_socket_type(type));
 
        *sock = (isc_nmsocket_t){ .type = type,
                                  .iface = iface,
@@ -1112,6 +1139,7 @@ void
 isc_nmhandle_ref(isc_nmhandle_t *handle) {
        REQUIRE(VALID_NMHANDLE(handle));
 
+fprintf(stderr, "ref %p (%p %s) to %lu\n", handle, handle->sock, isc__nm_socket_type(handle->sock->type), handle->references+1);
        isc_refcount_increment(&handle->references);
 }
 
@@ -1171,24 +1199,26 @@ isc_nmhandle_unref(isc_nmhandle_t *handle) {
 
        REQUIRE(VALID_NMHANDLE(handle));
 
+fprintf(stderr, "unref %p (%p %s) to %lu\n", handle, handle->sock, isc__nm_socket_type(handle->sock->type), handle->references-1);
        if (isc_refcount_decrement(&handle->references) > 1) {
                return;
        }
        /* We need an acquire memory barrier here */
        (void)isc_refcount_current(&handle->references);
 
+       /*
+        * XXX: Do we need to reference the socket to ensure that it
+        * can't be deleted by another thread while we're deactivating
+        * the handle?
+        */
        sock = handle->sock;
        handle->sock = NULL;
+fprintf(stderr, "handle %p sock %p set to NULL\n", handle, sock);
 
        if (handle->doreset != NULL) {
                handle->doreset(handle->opaque);
        }
 
-       /*
-        * Temporarily reference the socket to ensure that it can't
-        * be deleted by another thread while we're deactivating the
-        * handle.
-        */
        nmhandle_deactivate(sock, handle);
 
        /*
index 6ae5c111cf5725fa71216bffa4f25b1f6add9a7e..b10b8daa42199de23f3f119b1cb8ec91f8c6e6ad 100644 (file)
@@ -82,6 +82,7 @@ static void
 timer_close_cb(uv_handle_t *handle) {
        isc_nmsocket_t *sock = (isc_nmsocket_t *)uv_handle_get_data(handle);
        INSIST(VALID_NMSOCK(sock));
+fprintf(stderr, "timer close cb, sock %p\n", sock);
 }
 
 static void
@@ -102,6 +103,7 @@ dnslisten_acceptcb(isc_nmhandle_t *handle, isc_result_t result, void *cbarg) {
        isc_nmsocket_t *dnslistensock = (isc_nmsocket_t *)cbarg;
        isc_nmsocket_t *dnssock = NULL;
 
+fprintf(stderr, "dnslisten_acceptcb %p %s\n", handle, isc_result_totext(result));
        REQUIRE(VALID_NMSOCK(dnslistensock));
        REQUIRE(dnslistensock->type == isc_nm_tcpdnslistener);
 
@@ -221,6 +223,7 @@ dnslisten_readcb(isc_nmhandle_t *handle, isc_region_t *region, void *arg) {
        REQUIRE(VALID_NMHANDLE(handle));
        REQUIRE(dnssock->tid == isc_nm_tid());
 
+fprintf(stderr, "dnslisten_readcb %p (reg %p), sock %p (%s)\n", handle, handle->sock, region, handle->sock ?  isc__nm_socket_type(handle->sock->type) : "nil");
        if (region == NULL) {
                /* Connection closed */
                isc__nm_tcpdns_close(dnssock);
@@ -245,6 +248,7 @@ dnslisten_readcb(isc_nmhandle_t *handle, isc_region_t *region, void *arg) {
                isc_nmhandle_t *dnshandle = NULL;
 
                result = processbuffer(dnssock, &dnshandle);
+fprintf(stderr, "processbuffer sock %p with handle %p, result %s\n", dnssock, dnshandle, isc_result_totext(result));
                if (result != ISC_R_SUCCESS) {
                        /*
                         * There wasn't anything in the buffer to process.
@@ -416,6 +420,7 @@ resume_processing(void *arg) {
                isc_nmhandle_t *handle = NULL;
 
                result = processbuffer(sock, &handle);
+fprintf(stderr, "processed sequential sock %p with handle %p, result %s\n", sock, handle, isc_result_totext(result));
                if (result == ISC_R_SUCCESS) {
                        atomic_store(&sock->outerhandle->sock->processing,
                                     true);
@@ -438,6 +443,7 @@ resume_processing(void *arg) {
                isc_nmhandle_t *dnshandle = NULL;
 
                result = processbuffer(sock, &dnshandle);
+fprintf(stderr, "processed nonsequentially sock %p with handle %p, result %s\n", sock, dnshandle, isc_result_totext(result));
                if (result != ISC_R_SUCCESS) {
                        /*
                         * Nothing in the buffer; resume reading.
@@ -455,12 +461,15 @@ resume_processing(void *arg) {
                atomic_store(&sock->outerhandle->sock->processing, true);
                isc_nmhandle_unref(dnshandle);
        } while (atomic_load(&sock->ah) < TCPDNS_CLIENTS_PER_CONN);
+
+
 }
 
 static void
 tcpdnssend_cb(isc_nmhandle_t *handle, isc_result_t result, void *cbarg) {
        tcpsend_t *ts = (tcpsend_t *)cbarg;
 
+fprintf(stderr, "tcpdnssend_cb %p %s\n", handle, isc_result_totext(result));
        ts->cb(ts->orighandle, result, ts->cbarg);
        isc_mem_put(ts->mctx, ts->region.base, ts->region.length);
 
@@ -514,6 +523,8 @@ isc__nm_tcpdns_send(isc_nmhandle_t *handle, isc_region_t *region,
 static void
 tcpdns_close_direct(isc_nmsocket_t *sock) {
        REQUIRE(sock->tid == isc_nm_tid());
+
+fprintf(stderr, "close sock %p (tcpdns)\n", sock);
        /* We don't need atomics here, it's all in single network thread */
        if (sock->timer_initialized) {
                /*
@@ -523,23 +534,29 @@ tcpdns_close_direct(isc_nmsocket_t *sock) {
                 */
                sock->timer_initialized = false;
                uv_timer_stop(&sock->timer);
+fprintf(stderr, "closing timer\n");
                uv_close((uv_handle_t *)&sock->timer, timer_close_cb);
+fprintf(stderr, "...done\n");
        } else {
                /*
                 * At this point we're certain that there are no external
                 * references, we can close everything.
                 */
                if (sock->outerhandle != NULL) {
+fprintf(stderr, "clearing outerhandle\n");
                        sock->outerhandle->sock->rcb.recv = NULL;
                        isc_nmhandle_unref(sock->outerhandle);
                        sock->outerhandle = NULL;
                }
                if (sock->listener != NULL) {
+fprintf(stderr, "clearing listener\n");
                        isc__nmsocket_detach(&sock->listener);
                }
                atomic_store(&sock->closed, true);
+fprintf(stderr, "prep socket destruction\n");
                isc__nmsocket_prep_destroy(sock);
        }
+fprintf(stderr, "closed\n");
 }
 
 void