]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
dnstap io, fix event reference in winevent wouldblock call.
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Thu, 23 Jan 2020 15:49:44 +0000 (16:49 +0100)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Thu, 23 Jan 2020 15:49:44 +0000 (16:49 +0100)
dnstap/dtstream.c
dnstap/dtstream.h

index aa590ee8f02c3014980a0d13e55cfe66411af44d..8a4eefbf2963c6aa75bf90bc71037e521dce9ff1 100644 (file)
@@ -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);
index 2f15465277ca0048e67d64ebe8ab0cacad9bd7e6..3386a1897508800e5fd7add034745e74a92a3780 100644 (file)
@@ -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 */