From: W.C.A. Wijngaards Date: Fri, 14 Feb 2020 14:41:17 +0000 (+0100) Subject: dnstap io, fix spinning reconnect when handshake fails for TLS. X-Git-Tag: 1.11.0rc1~120^2~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7b19ba3d57138871c8c17ac22acfa301847892fa;p=thirdparty%2Funbound.git dnstap io, fix spinning reconnect when handshake fails for TLS. --- diff --git a/dnstap/dtstream.c b/dnstap/dtstream.c index ba545dd7c..27a3d570c 100644 --- a/dnstap/dtstream.c +++ b/dnstap/dtstream.c @@ -65,6 +65,8 @@ #define DTIO_RECONNECT_TIMEOUT_MIN 10 /** the msec to wait for reconnect max after backoff */ #define DTIO_RECONNECT_TIMEOUT_MAX 1000 +/** the msec to wait for reconnect slow, to stop busy spinning on reconnect */ +#define DTIO_RECONNECT_TIMEOUT_SLOW 1000 struct stop_flush_info; /** DTIO command channel commands */ @@ -529,6 +531,14 @@ static void dtio_reconnect_clear(struct dt_io_thread* dtio) dtio_reconnect_del(dtio); } +/** reconnect slowly, because we already know we have to wait for a bit */ +static void dtio_reconnect_slow(struct dt_io_thread* dtio, int msec) +{ + dtio_reconnect_del(dtio); + dtio->reconnect_timeout = msec; + dtio_reconnect_enable(dtio); +} + /** delete the current message in the dtio, and reset counters */ static void dtio_cur_msg_free(struct dt_io_thread* dtio) { @@ -1078,6 +1088,7 @@ static int dtio_ssl_handshake(struct dt_io_thread* dtio, /* closed */ if(info) dtio_stop_flush_exit(info); dtio_del_output_event(dtio); + dtio_reconnect_slow(dtio, DTIO_RECONNECT_TIMEOUT_SLOW); dtio_close_output(dtio); return 0; } else if(want == SSL_ERROR_SYSCALL) { @@ -1099,6 +1110,7 @@ static int dtio_ssl_handshake(struct dt_io_thread* dtio, /* closed */ if(info) dtio_stop_flush_exit(info); dtio_del_output_event(dtio); + dtio_reconnect_slow(dtio, DTIO_RECONNECT_TIMEOUT_SLOW); dtio_close_output(dtio); return 0; } else { @@ -1112,6 +1124,7 @@ static int dtio_ssl_handshake(struct dt_io_thread* dtio, /* closed */ if(info) dtio_stop_flush_exit(info); dtio_del_output_event(dtio); + dtio_reconnect_slow(dtio, DTIO_RECONNECT_TIMEOUT_SLOW); dtio_close_output(dtio); return 0; } @@ -1124,6 +1137,7 @@ static int dtio_ssl_handshake(struct dt_io_thread* dtio, /* closed */ if(info) dtio_stop_flush_exit(info); dtio_del_output_event(dtio); + dtio_reconnect_slow(dtio, DTIO_RECONNECT_TIMEOUT_SLOW); dtio_close_output(dtio); return 0; }