From: Remi Gacogne Date: Mon, 21 Sep 2020 15:24:55 +0000 (+0200) Subject: rec: Watch the descriptor again after an out-of-order read timeout X-Git-Tag: auth-4.4.0-alpha1~11^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b05ef1b472cfa3597dda44075f3947abd565008b;p=thirdparty%2Fpdns.git rec: Watch the descriptor again after an out-of-order read timeout It might be that there was no other incoming query on that connection and we timed out while the response had not been sent yet, but the client might want to re-use the connection after receving the response. We try to reset the TTD, but that might fail when the socket descriptor has already been removed. --- diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 09663e3f99..4553101703 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -1910,11 +1910,15 @@ static void startDoResolve(void *p) ttd.tv_sec += g_tcpTimeout; t_fdm->addReadFD(dc->d_socket, handleRunningTCPQuestion, dc->d_tcpConnection, &ttd); } else { - // fd might have been removed by read error code, so expect an exception + // fd might have been removed by read error code, or a read timeout, so expect an exception try { t_fdm->setReadTTD(dc->d_socket, ttd, g_tcpTimeout); } - catch (FDMultiplexerException &) { + catch (const FDMultiplexerException &) { + // but the FD was removed because of a timeout while we were sending a response, + // we need to re-arm it. If it was an error it will error again. + ttd.tv_sec += g_tcpTimeout; + t_fdm->addReadFD(dc->d_socket, handleRunningTCPQuestion, dc->d_tcpConnection, &ttd); } } }