]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rec: Watch the descriptor again after an out-of-order read timeout
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 21 Sep 2020 15:24:55 +0000 (17:24 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 21 Sep 2020 15:24:55 +0000 (17:24 +0200)
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.

pdns/pdns_recursor.cc

index 09663e3f99fb9599d63674bb2cc9d7d7be6e7c8e..45531017038d2832959d52ba2776dee11786069a 100644 (file)
@@ -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);
             }
           }
         }