From: W.C.A. Wijngaards Date: Thu, 23 Jan 2020 15:49:44 +0000 (+0100) Subject: dnstap io, fix event reference in winevent wouldblock call. X-Git-Tag: 1.11.0rc1~120^2~83 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f2f004778301c75cc4231f104d3096dc35ac941;p=thirdparty%2Funbound.git dnstap io, fix event reference in winevent wouldblock call. --- diff --git a/dnstap/dtstream.c b/dnstap/dtstream.c index aa590ee8f..8a4eefbf2 100644 --- a/dnstap/dtstream.c +++ b/dnstap/dtstream.c @@ -506,7 +506,7 @@ static int dtio_check_nb_connect(struct dt_io_thread* dtio) if(error == WSAEINPROGRESS) { return 0; /* try again later */ } else if(error == WSAEWOULDBLOCK) { - ub_winsock_tcp_wouldblock(dtio->event, UB_EV_WRITE); + ub_winsock_tcp_wouldblock((dtio->stop_flush_event?dtio->stop_flush_event:dtio->event), UB_EV_WRITE); return 0; /* try again later */ } #endif @@ -555,7 +555,7 @@ static int dtio_write_buf(struct dt_io_thread* dtio, uint8_t* buf, if(WSAGetLastError() == WSAEINPROGRESS) return 0; if(WSAGetLastError() == WSAEWOULDBLOCK) { - ub_winsock_tcp_wouldblock(dtio->event, UB_EV_WRITE); + ub_winsock_tcp_wouldblock((dtio->stop_flush_event?dtio->stop_flush_event:dtio->event), UB_EV_WRITE); return 0; } log_err("dnstap io: failed send: %s", @@ -600,7 +600,7 @@ static int dtio_write_with_writev(struct dt_io_thread* dtio) if(WSAGetLastError() == WSAEINPROGRESS) return 0; if(WSAGetLastError() == WSAEWOULDBLOCK) { - ub_winsock_tcp_wouldblock(dtio->event, UB_EV_WRITE); + ub_winsock_tcp_wouldblock((dtio->stop_flush_event?dtio->stop_flush_event:dtio->event), UB_EV_WRITE); return 0; } log_err("dnstap io: failed writev: %s", @@ -720,7 +720,7 @@ static int dtio_check_close(struct dt_io_thread* dtio) if(WSAGetLastError() == WSAEINPROGRESS) { return 1; /* try later */ } else if(WSAGetLastError() == WSAEWOULDBLOCK) { - ub_winsock_tcp_wouldblock(dtio->event, UB_EV_READ); + ub_winsock_tcp_wouldblock((dtio->stop_flush_event?dtio->stop_flush_event:dtio->event), UB_EV_READ); return 1; /* try later */ } #endif @@ -1098,6 +1098,7 @@ static void dtio_control_stop_flush(struct dt_io_thread* dtio) ub_event_base_free(info.base); return; } + dtio->stop_flush_event = stopev; /* wait briefly, or until finished */ verbose(VERB_ALGO, "dnstap io: stop flush started"); @@ -1107,6 +1108,7 @@ static void dtio_control_stop_flush(struct dt_io_thread* dtio) } verbose(VERB_ALGO, "dnstap io: stop flush ended"); free(info.stop_frame); + dtio->stop_flush_event = NULL; ub_event_del(stopev); ub_event_free(stopev); ub_timer_del(timer); diff --git a/dnstap/dtstream.h b/dnstap/dtstream.h index 2f1546527..3386a1897 100644 --- a/dnstap/dtstream.h +++ b/dnstap/dtstream.h @@ -133,6 +133,9 @@ struct dt_io_thread { /** the io thread wants to exit */ int want_to_exit; + /** in stop flush, this is nonNULL and references the stop_ev */ + void* stop_flush_event; + /** the timer event for connection retries */ void* reconnect_timer; /** if the reconnect timer is added to the event base */