]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
in tcp write callback routine dont reset read byte count if write and read.
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Fri, 26 Jun 2020 08:54:13 +0000 (10:54 +0200)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Fri, 26 Jun 2020 08:54:13 +0000 (10:54 +0200)
in tcp write callback and write and read and write is done perform callback.
tcp connection is selected to not toggle readwrite and give closed callback.

services/outside_network.c
util/netevent.c

index ee8275c7f710a4792b4d044d502e9cd2570ac6eb..8da5eeb64dd48240112716b902160b2304baf8c7 100644 (file)
@@ -516,6 +516,8 @@ outnet_tcp_take_into_use(struct waiting_tcp* w)
        log_assert(w->pkt);
        log_assert(w->pkt_len > 0);
        log_assert(w->addrlen > 0);
+       pend->c->tcp_do_toggle_rw = 0;
+       pend->c->tcp_do_close = 0;
        /* open socket */
        s = outnet_get_tcp_fd(&w->addr, w->addrlen, w->outnet->tcp_mss, w->outnet->ip_dscp);
 
index 2ca92b92dcce999a9b572cd863ee3fb6cdaa1a8a..bcff7a590a916af1fc10d012e8c030dcebff25c7 100644 (file)
@@ -995,13 +995,23 @@ tcp_callback_writer(struct comm_point* c)
        sldns_buffer_clear(c->buffer);
        if(c->tcp_do_toggle_rw)
                c->tcp_is_reading = 1;
-       c->tcp_byte_count = 0;
+       if(!c->tcp_write_and_read)
+               c->tcp_byte_count = 0;
        /* switch from listening(write) to listening(read) */
        if(c->tcp_req_info) {
                tcp_req_info_handle_writedone(c->tcp_req_info);
        } else {
                comm_point_stop_listening(c);
-               comm_point_start_listening(c, -1, c->tcp_timeout_msec);
+               if(c->tcp_write_and_read) {
+                       fptr_ok(fptr_whitelist_comm_point(c->callback));
+                       if( (*c->callback)(c, c->cb_arg, NETEVENT_PKT_WRITTEN,
+                               &c->repinfo) ) {
+                               comm_point_start_listening(c, -1,
+                                       c->tcp_timeout_msec);
+                       }
+               } else {
+                       comm_point_start_listening(c, -1, c->tcp_timeout_msec);
+               }
        }
 }