From 64c8d18814d09a66f47dcae79e2ade94f198166c Mon Sep 17 00:00:00 2001 From: "W.C.A. Wijngaards" Date: Fri, 26 Jun 2020 10:54:13 +0200 Subject: [PATCH] in tcp write callback routine dont reset read byte count if write and read. 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 | 2 ++ util/netevent.c | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/services/outside_network.c b/services/outside_network.c index ee8275c7f..8da5eeb64 100644 --- a/services/outside_network.c +++ b/services/outside_network.c @@ -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); diff --git a/util/netevent.c b/util/netevent.c index 2ca92b92d..bcff7a590 100644 --- a/util/netevent.c +++ b/util/netevent.c @@ -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); + } } } -- 2.47.3