]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
auth zone work.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 8 Feb 2018 11:59:30 +0000 (11:59 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 8 Feb 2018 11:59:30 +0000 (11:59 +0000)
git-svn-id: file:///svn/unbound/trunk@4521 be551aaa-1e26-0410-a405-d3ace91eadb9

services/authzone.c
services/outside_network.c
util/netevent.c
util/netevent.h

index 8f1c2ea9054ab2eb525c2fba6fbf5f21bbbdca73..7e9f0287421647c0fd55988457e3c8c2c5378ed5 100644 (file)
@@ -3766,7 +3766,7 @@ static int
 http_zonefile_syntax_check(struct auth_xfer* xfr, sldns_buffer* buf)
 {
        uint8_t rr[LDNS_RR_BUF_SIZE];
-       size_t rr_len = 0, dname_len = 0;
+       size_t rr_len, dname_len = 0;
        struct auth_chunk* chunk;
        size_t chunk_pos;
        int e;
@@ -3775,6 +3775,7 @@ http_zonefile_syntax_check(struct auth_xfer* xfr, sldns_buffer* buf)
        if(!chunkline_non_comment_RR(&chunk, &chunk_pos, buf)) {
                return 0;
        }
+       rr_len = sizeof(rr);
        e=sldns_str2wire_rr_buf((char*)sldns_buffer_begin(buf), rr, &rr_len,
                &dname_len, 3600, NULL, 0, NULL, 0);
        if(e != 0) {
@@ -5089,6 +5090,8 @@ auth_xfer_transfer_http_callback(struct comm_point* c, void* arg, int err,
        /* if it is good, link it into the list of data */
        /* if the link into list of data fails (malloc fail) cleanup and end */
        if(sldns_buffer_limit(c->buffer) > 0) {
+               verbose(VERB_ALGO, "auth zone http queued up %d bytes",
+                       (int)sldns_buffer_limit(c->buffer));
                if(!xfer_link_data(c->buffer, xfr)) {
                        verbose(VERB_ALGO, "http stopped to %s, malloc failed",
                                xfr->task_transfer->master->host);
@@ -5506,6 +5509,18 @@ auth_xfer_timer(void* arg)
        /* see if we need to start a probe (or maybe it is already in
         * progress (due to notify)) */
        if(xfr->task_probe->worker == NULL) {
+               if(xfr->task_probe->masters == NULL) {
+                       /* useless to pick up task_probe, no masters to
+                        * probe. Instead attempt to pick up task transfer */
+                       if(xfr->task_transfer->worker == NULL) {
+                               xfr_start_transfer(xfr, env, NULL);
+                       } else {
+                               /* task transfer already in progress */
+                               lock_basic_unlock(&xfr->lock);
+                       }
+                       return;
+               }
+
                /* pick up the probe task ourselves */
                xfr->task_probe->worker = env->worker;
                xfr->task_probe->env = env;
index 0507d5a49c741b23d537a856c71c3e0e9fc5e9e9..ee205ade81f6d4c1af4ea2e5338965ba30f0b9d6 100644 (file)
@@ -2327,7 +2327,7 @@ outnet_comm_point_for_http(struct outside_network* outnet,
                comm_point_delete(cp);
                return NULL;
        }
-       return NULL;
+       return cp;
 }
 
 /** get memory used by waiting tcp entry (in use or not) */
index 10795cbe937790fda951dcb4eacf9211261390f6..c9ce80080032cb14c65e43e96eda6bfa9e450fc0 100644 (file)
@@ -1723,7 +1723,7 @@ http_header_line(sldns_buffer* buf)
                /* terminate on the \n and skip past the it and done */
                if((char)sldns_buffer_read_u8_at(buf, i) == '\n') {
                        sldns_buffer_write_u8_at(buf, i, 0);
-                       sldns_buffer_set_position(buf, i);
+                       sldns_buffer_set_position(buf, i+1);
                        return result;
                }
        }
@@ -1815,11 +1815,6 @@ http_process_chunk_header(struct comm_point* c)
                c->tcp_byte_count = (size_t)strtol(line, &end, 16);
                if(end == line)
                        return 0;
-               c->http_in_chunk_headers = 2;
-               return 1;
-       }
-       if(line[0] == 0) {
-               /* end of chunk headers */
                c->http_in_chunk_headers = 0;
                /* remove header text from front of buffer */
                http_moveover_buffer(c->buffer);
@@ -1828,6 +1823,7 @@ http_process_chunk_header(struct comm_point* c)
                        /* done with chunks, process chunk_trailer lines */
                        c->http_in_chunk_headers = 3;
                }
+               return 1;
        }
        /* ignore other headers */
        return 1;
@@ -1915,6 +1911,7 @@ http_chunked_segment(struct comm_point* c)
                sldns_buffer_write(c->buffer,
                        sldns_buffer_begin(c->http_temp),
                        sldns_buffer_remaining(c->http_temp));
+               sldns_buffer_flip(c->buffer);
                /* process end of chunk trailer header lines, until
                 * an empty line */
                c->http_in_chunk_headers = 3;
@@ -1955,9 +1952,6 @@ static int
 comm_point_http_handle_read(int fd, struct comm_point* c)
 {
        log_assert(c->type == comm_http);
-       if(!c->tcp_is_reading)
-               return 0;
-
        log_assert(fd != -1);
 
        /* if we are in ssl handshake, handle SSL handshake */
@@ -1968,6 +1962,8 @@ comm_point_http_handle_read(int fd, struct comm_point* c)
                        return 1;
        }
 
+       if(!c->tcp_is_reading)
+               return 1;
        /* read more data */
        if(c->ssl) {
                if(!ssl_http_read_more(c))
@@ -2146,9 +2142,6 @@ static int
 comm_point_http_handle_write(int fd, struct comm_point* c)
 {
        log_assert(c->type == comm_http);
-       if(c->tcp_is_reading)
-               return 0;
-
        log_assert(fd != -1);
 
        /* check pending connect errors, if that fails, we wait for more,
@@ -2166,6 +2159,8 @@ comm_point_http_handle_write(int fd, struct comm_point* c)
                if(c->ssl_shake_state != comm_ssl_shake_none)
                        return 1;
        }
+       if(c->tcp_is_reading)
+               return 1;
        /* if we are writing, write more */
        if(c->ssl) {
                if(!ssl_http_write_more(c))
@@ -2811,7 +2806,7 @@ comm_point_delete(struct comm_point* c)
 {
        if(!c) 
                return;
-       if(c->type == comm_tcp && c->ssl) {
+       if((c->type == comm_tcp || c->type == comm_http) && c->ssl) {
 #ifdef HAVE_SSL
                SSL_shutdown(c->ssl);
                SSL_free(c->ssl);
@@ -2825,7 +2820,7 @@ comm_point_delete(struct comm_point* c)
                free(c->tcp_handlers);
        }
        free(c->timeout);
-       if(c->type == comm_tcp || c->type == comm_local) {
+       if(c->type == comm_tcp || c->type == comm_local || c->type == comm_http) {
                sldns_buffer_free(c->buffer);
 #ifdef USE_DNSCRYPT
                if(c->dnscrypt && c->dnscrypt_buffer != c->buffer) {
index 4f73ab7f5c4f05cac50e338b3351e3e30d1b8341..e34ab564021371f339cc01948120bcb84771f53d 100644 (file)
@@ -206,8 +206,8 @@ struct comm_point {
        /* -------- HTTP ------- */
        /** Currently reading in http headers */
        int http_in_headers;
-       /** Currently reading in chunk headers, 0=not, 1=firstline, 2=rest
-        * of chunk header, 3=trailer headers after chunk */
+       /** Currently reading in chunk headers, 0=not, 1=firstline, 2=unused
+        * (more lines), 3=trailer headers after chunk */
        int http_in_chunk_headers;
        /** chunked transfer */
        int http_is_chunked;