From: Wouter Wijngaards Date: Tue, 15 Jan 2019 10:27:00 +0000 (+0000) Subject: - Review fixes in out of order processing. X-Git-Tag: release-1.9.0rc1~49 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0d2efc3f3f1e3e6fff4e660867bb6efb1dea060a;p=thirdparty%2Funbound.git - Review fixes in out of order processing. git-svn-id: file:///svn/unbound/trunk@5035 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/doc/Changelog b/doc/Changelog index 09e4d96c0..04cd0461e 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,6 +1,7 @@ 15 January 2018: Wouter - In the out of order processing, reset byte count for (potential) partial read. + - Review fixes in out of order processing. 14 January 2018: Wouter - streamtcp option -a send queries consecutively and prints answers diff --git a/services/listen_dnsport.c b/services/listen_dnsport.c index 7db018f6d..b931d17b3 100644 --- a/services/listen_dnsport.c +++ b/services/listen_dnsport.c @@ -1691,6 +1691,11 @@ tcp_req_info_handle_writedone(struct tcp_req_info* req) { /* back to reading state, we finished this write event */ sldns_buffer_clear(req->cp->buffer); + if(req->num_done_req == 0 && req->read_is_closed) { + /* no more to write and nothing to read, close it */ + comm_point_drop_reply(&req->cp->repinfo); + return; + } req->cp->tcp_is_reading = 1; /* see if another result needs writing */ tcp_req_pickup_next_result(req); @@ -1712,7 +1717,10 @@ tcp_req_info_handle_readdone(struct tcp_req_info* req) req->is_drop = 0; req->is_reply = 0; req->in_worker_handle = 1; - /* handle the current request, */ + /* handle the current request */ + /* this calls the worker handle request routine that could give + * a cache response, or localdata response, or drop the reply, + * or schedule a mesh entry for later */ fptr_ok(fptr_whitelist_comm_point(c->callback)); if( (*c->callback)(c, c->cb_arg, NETEVENT_NOERROR, &c->repinfo) ) { req->in_worker_handle = 0; @@ -1727,9 +1735,16 @@ tcp_req_info_handle_readdone(struct tcp_req_info* req) } req->in_worker_handle = 0; /* it should be waiting in the mesh for recursion. - * If mesh failed(formerr) and called commpoint_drop_reply. Then the - * mesh state has been cleared. */ + * If mesh failed to add a new entry and called commpoint_drop_reply. + * Then the mesh state has been cleared. */ if(req->is_drop) { + /* we can now call drop_reply without recursing into ourselves + * whilst in the callback */ + /* we have to close the stream because there is no reply, + * no servfail to send, but the query needs an action, for + * a stream that is close the connection */ + sldns_buffer_clear(c->buffer); + comm_point_drop_reply(&c->repinfo); return; } /* If mesh failed(mallocfail) and called commpoint_send_reply with @@ -1738,7 +1753,7 @@ tcp_req_info_handle_readdone(struct tcp_req_info* req) goto send_it; } - sldns_buffer_clear(req->cp->buffer); + sldns_buffer_clear(c->buffer); /* if pending answers, pick up an answer and start sending it */ tcp_req_pickup_next_result(req);