]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Clean the ENTER/EXIT/NOTICE debugging from production code
authorOndřej Surý <ondrej@isc.org>
Tue, 21 Jan 2020 07:25:30 +0000 (08:25 +0100)
committerOndřej Surý <ondrej@isc.org>
Sat, 8 Feb 2020 19:46:37 +0000 (11:46 -0800)
(cherry picked from commit 5b448996e51609b2ed9c9a8c3a952f70e695694f)

lib/isc/httpd.c

index acb97952b1f63157960ecbe88dc5ea59625fa73e..62593470d233381e7237fe6248a2c7b2a9e53a6a 100644 (file)
 #define MSHUTTINGDOWN(cm) ((cm->flags & ISC_HTTPDMGR_FLAGSHUTTINGDOWN) != 0)
 #define MSETSHUTTINGDOWN(cm) (cm->flags |= ISC_HTTPDMGR_FLAGSHUTTINGDOWN)
 
-#ifdef DEBUG_HTTPD
-#define ENTER(x) do { fprintf(stderr, "ENTER %s\n", (x)); } while (0)
-#define EXIT(x) do { fprintf(stderr, "EXIT %s\n", (x)); } while (0)
-#define NOTICE(x) do { fprintf(stderr, "NOTICE %s\n", (x)); } while (0)
-#else
-#define ENTER(x) do { } while(0)
-#define EXIT(x) do { } while(0)
-#define NOTICE(x) do { } while(0)
-#endif
-
 #define HTTP_RECVLEN                   1024
 #define HTTP_SENDGROW                  1024
 #define HTTP_SEND_MAXLEN               10240
@@ -309,7 +299,7 @@ httpdmgr_socket_accept(isc_task_t *task, isc_httpdmgr_t* httpdmgr)
        return (result);
 }
 
-static inline isc_result_t
+static inline void
 httpd_socket_recv(isc_httpd_t *httpd, isc_region_t *region, isc_task_t *task)
 {
        isc_result_t result = ISC_R_SUCCESS;
@@ -323,11 +313,11 @@ httpd_socket_recv(isc_httpd_t *httpd, isc_region_t *region, isc_task_t *task)
                isc_refcount_decrement(&httpd->references, &refs);
                INSIST(refs > 0);
        }
-       return (result);
 }
 
 static inline isc_result_t
-httpd_socket_send(isc_httpd_t *httpd, isc_task_t *task) {
+httpd_socket_send(isc_httpd_t *httpd, isc_task_t *task)
+{
        isc_result_t result = ISC_R_SUCCESS;
 
        /* decremented in isc_httpd_senddone */
@@ -462,8 +452,6 @@ destroy_httpdmgr(isc_httpdmgr_t *httpdmgr) {
        INSIST(MSHUTTINGDOWN(httpdmgr));
        INSIST(ISC_LIST_EMPTY(httpdmgr->running));
 
-       NOTICE("httpdmgr_destroy detaching socket, task, and timermgr");
-
        isc_socket_detach(&httpdmgr->sock);
        isc_task_detach(&httpdmgr->task);
        httpdmgr->timermgr = NULL;
@@ -565,8 +553,6 @@ process_request(isc_httpd_t *httpd, int length) {
        char *p;
        int delim;
 
-       ENTER("request");
-
        httpd->recvlen += length;
 
        httpd->recvbuf[httpd->recvlen] = 0;
@@ -716,8 +702,6 @@ process_request(isc_httpd_t *httpd, int length) {
            && ((httpd->flags & HTTPD_FOUNDHOST) == 0))
                return (ISC_R_RANGE);
 
-       EXIT("request");
-
        return (ISC_R_SUCCESS);
 }
 
@@ -773,7 +757,6 @@ isc_httpd_create(isc_httpdmgr_t *httpdmgr, isc_socket_t *sock,
 
 static void
 isc_httpd_accept(isc_task_t *task, isc_event_t *ev) {
-       isc_result_t result;
        isc_httpdmgr_t *httpdmgr = ev->ev_arg;
        isc_httpd_t *httpd = NULL;
        isc_region_t r;
@@ -782,22 +765,17 @@ isc_httpd_accept(isc_task_t *task, isc_event_t *ev) {
 
        REQUIRE(VALID_HTTPDMGR(httpdmgr));
 
-       ENTER("accept");
-
        LOCK(&httpdmgr->lock);
        if (MSHUTTINGDOWN(httpdmgr)) {
-               NOTICE("accept shutting down, goto out");
                goto out;
        }
 
        if (nev->result == ISC_R_CANCELED) {
-               NOTICE("accept canceled, goto out");
                goto out;
        }
 
        if (nev->result != ISC_R_SUCCESS) {
                /* XXXMLG log failure */
-               NOTICE("accept returned failure, goto requeue");
                goto requeue;
        }
 
@@ -817,16 +795,10 @@ isc_httpd_accept(isc_task_t *task, isc_event_t *ev) {
        r.base = (unsigned char *)httpd->recvbuf;
        r.length = HTTP_RECVLEN - 1;
 
-       result = httpd_socket_recv(httpd, &r, task);
-       if (result == ISC_R_SUCCESS) {
-               NOTICE("accept queued recv on socket");
-       }
+       httpd_socket_recv(httpd, &r, task);
 
  requeue:
-       result = httpdmgr_socket_accept(task, httpdmgr);
-       if (result != ISC_R_SUCCESS) {
-               NOTICE("accept could not reaccept due to failure");
-       }
+       (void)httpdmgr_socket_accept(task, httpdmgr);
 
  out:
        UNLOCK(&httpdmgr->lock);
@@ -837,8 +809,6 @@ isc_httpd_accept(isc_task_t *task, isc_event_t *ev) {
        maybe_destroy_httpdmgr(httpdmgr);
 
        isc_event_free(&ev);
-
-       EXIT("accept");
 }
 
 static isc_result_t
@@ -993,12 +963,9 @@ isc_httpd_recvdone(isc_task_t *task, isc_event_t *ev) {
 
        REQUIRE(VALID_HTTPD(httpd));
 
-       ENTER("recv");
-
        INSIST(ISC_HTTPD_ISRECV(httpd));
 
        if (sev->result != ISC_R_SUCCESS) {
-               NOTICE("recv destroying client");
                goto out;
        }
 
@@ -1128,7 +1095,6 @@ isc_httpd_recvdone(isc_task_t *task, isc_event_t *ev) {
  out:
        maybe_destroy_httpd(httpd);
        isc_event_free(&ev);
-       EXIT("recv");
 }
 
 void
@@ -1141,8 +1107,6 @@ isc_httpdmgr_shutdown(isc_httpdmgr_t **httpdmgrp) {
        *httpdmgrp = NULL;
        REQUIRE(VALID_HTTPDMGR(httpdmgr));
 
-       ENTER("isc_httpdmgr_shutdown");
-
        LOCK(&httpdmgr->lock);
 
        MSETSHUTTINGDOWN(httpdmgr);
@@ -1160,7 +1124,6 @@ isc_httpdmgr_shutdown(isc_httpdmgr_t **httpdmgrp) {
 
        maybe_destroy_httpdmgr(httpdmgr);
 
-       EXIT("isc_httpdmgr_shutdown");
 }
 
 static isc_result_t
@@ -1300,7 +1263,6 @@ isc_httpd_senddone(isc_task_t *task, isc_event_t *ev) {
 
        REQUIRE(VALID_HTTPD(httpd));
 
-       ENTER("senddone");
        INSIST(ISC_HTTPD_ISSEND(httpd));
 
        /*
@@ -1308,7 +1270,6 @@ isc_httpd_senddone(isc_task_t *task, isc_event_t *ev) {
         * is sort of an evil hack, since we know our buffer will be there,
         * and we know it's address, so we can just remove it directly.
         */
-       NOTICE("senddone unlinked header");
        ISC_LIST_UNLINK(sev->bufferlist, &httpd->headerbuffer, link);
 
        /*
@@ -1324,14 +1285,11 @@ isc_httpd_senddone(isc_task_t *task, isc_event_t *ev) {
                        b = &httpd->bodybuffer;
                        httpd->freecb(b, httpd->freecb_arg);
                }
-               NOTICE("senddone free callback performed");
        }
        if (ISC_LINK_LINKED(&httpd->bodybuffer, link)) {
                ISC_LIST_UNLINK(sev->bufferlist, &httpd->bodybuffer, link);
-               NOTICE("senddone body buffer unlinked");
        } else if (ISC_LINK_LINKED(&httpd->compbuffer, link)) {
                ISC_LIST_UNLINK(sev->bufferlist, &httpd->compbuffer, link);
-               NOTICE("senddone compressed data unlinked and freed");
        }
 
        if (sev->result != ISC_R_SUCCESS) {
@@ -1344,8 +1302,6 @@ isc_httpd_senddone(isc_task_t *task, isc_event_t *ev) {
 
        ISC_HTTPD_SETRECV(httpd);
 
-       NOTICE("senddone restarting recv on socket");
-
        reset_client(httpd);
 
        r.base = (unsigned char *)httpd->recvbuf;
@@ -1356,7 +1312,6 @@ isc_httpd_senddone(isc_task_t *task, isc_event_t *ev) {
 out:
        maybe_destroy_httpd(httpd);
        isc_event_free(&ev);
-       EXIT("senddone");
 }
 
 static void