]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Cleanup TCPIOHandler constructor
authorFred Morcos <fred.morcos@open-xchange.com>
Wed, 15 Feb 2023 15:15:18 +0000 (16:15 +0100)
committerFred Morcos <fred.morcos@open-xchange.com>
Mon, 20 Feb 2023 10:22:48 +0000 (11:22 +0100)
pdns/dnsdistdist/dnsdist-discovery.cc
pdns/dnsdistdist/dnsdist-healthchecks.cc
pdns/dnsdistdist/dnsdist-tcp-downstream.cc
pdns/recursordist/lwres.cc
pdns/recursordist/rec-carbon.cc
pdns/recursordist/ws-recursor.cc
pdns/sdig.cc
pdns/tcpiohandler.hh

index c042fa52f9e0c56edee2a7ea616a0ca54ac9df6f..9d267ecded515f8aaba6152e0bb52e8659d19b10 100644 (file)
@@ -367,8 +367,7 @@ static bool checkBackendUsability(std::shared_ptr<DownstreamState>& ds)
       sock.bind(ds->d_config.sourceAddr);
     }
 
-    time_t now = time(nullptr);
-    auto handler = std::make_unique<TCPIOHandler>(ds->d_config.d_tlsSubjectName, ds->d_config.d_tlsSubjectIsAddr, sock.releaseHandle(), timeval{ds->d_config.checkTimeout, 0}, ds->d_tlsCtx, now);
+    auto handler = std::make_unique<TCPIOHandler>(ds->d_config.d_tlsSubjectName, ds->d_config.d_tlsSubjectIsAddr, sock.releaseHandle(), timeval{ds->d_config.checkTimeout, 0}, ds->d_tlsCtx);
     handler->connect(ds->d_config.tcpFastOpen, ds->d_config.remote, timeval{ds->d_config.checkTimeout, 0});
     return true;
   }
index 3f8555f35bbe304509fa67d7b87d7cb7e975b815..4a5205227626e605de8776a10bc7cdc7b78449c0 100644 (file)
@@ -360,7 +360,7 @@ bool queueHealthCheck(std::unique_ptr<FDMultiplexer>& mplexer, const std::shared
     }
     else {
       time_t now = time(nullptr);
-      data->d_tcpHandler = std::make_unique<TCPIOHandler>(ds->d_config.d_tlsSubjectName, ds->d_config.d_tlsSubjectIsAddr, sock.releaseHandle(), timeval{ds->d_config.checkTimeout,0}, ds->d_tlsCtx, now);
+      data->d_tcpHandler = std::make_unique<TCPIOHandler>(ds->d_config.d_tlsSubjectName, ds->d_config.d_tlsSubjectIsAddr, sock.releaseHandle(), timeval{ds->d_config.checkTimeout,0}, ds->d_tlsCtx);
       data->d_ioState = std::make_unique<IOStateHandler>(*mplexer, data->d_tcpHandler->getDescriptor());
       if (ds->d_tlsCtx) {
         try {
index a6ab7002f21bef9cc8774798c6d1a800cd6e2e74..6c6fcf222902d0bafc5e1aba580b168d09a7d7a9 100644 (file)
@@ -103,7 +103,7 @@ bool ConnectionToBackend::reconnect()
       socket.setNonBlocking();
 
       gettimeofday(&d_connectionStartTime, nullptr);
-      auto handler = std::make_unique<TCPIOHandler>(d_ds->d_config.d_tlsSubjectName, d_ds->d_config.d_tlsSubjectIsAddr, socket.releaseHandle(), timeval{0,0}, d_ds->d_tlsCtx, d_connectionStartTime.tv_sec);
+      auto handler = std::make_unique<TCPIOHandler>(d_ds->d_config.d_tlsSubjectName, d_ds->d_config.d_tlsSubjectIsAddr, socket.releaseHandle(), timeval{0,0}, d_ds->d_tlsCtx);
       if (!tlsSession && d_ds->d_tlsCtx) {
         tlsSession = g_sessionCache.getSession(d_ds->getID(), d_connectionStartTime.tv_sec);
       }
index 40e44fc65953323ae4b2b39fefd7f3ac327edd27..b63f53f9bd386a5039848fc8b54a3425f9fba4fe 100644 (file)
@@ -314,7 +314,7 @@ static bool tcpconnect(const struct timeval& now, const ComboAddress& ip, TCPOut
       dnsOverTLS = false;
     }
   }
-  connection.d_handler = std::make_shared<TCPIOHandler>(nsName, false, s.releaseHandle(), timeout, tlsCtx, now.tv_sec);
+  connection.d_handler = std::make_shared<TCPIOHandler>(nsName, false, s.releaseHandle(), timeout, tlsCtx);
   // Returned state ignored
   // This can throw an exception, retry will need to happen at higher level
   connection.d_handler->tryConnect(SyncRes::s_tcp_fast_open_connect, ip);
index 43b1df9570ca594bf98150dc277f731c8f76ca5a..d0f77742cc755fde6e0864a967817746061cec91 100644 (file)
@@ -49,7 +49,7 @@ void doCarbonDump(void*)
       {
         g_networkTimeoutMsec / 1000, static_cast<suseconds_t>(g_networkTimeoutMsec) % 1000 * 1000
       };
-      auto handler = std::make_shared<TCPIOHandler>("", false, s.releaseHandle(), timeout, tlsCtx, time(nullptr));
+      auto handler = std::make_shared<TCPIOHandler>("", false, s.releaseHandle(), timeout, tlsCtx);
       handler->tryConnect(SyncRes::s_tcp_fast_open_connect, remote); // we do the connect so the first attempt happens while we gather stats
 
       if (msg.empty()) {
index 21ddd01ee998c8b29b59a51fea7d5e81f9d6882a..c5ca3ccc66ea4a88d26ce6385bc4d1951992a646 100644 (file)
@@ -1408,7 +1408,7 @@ void AsyncWebServer::serveConnection(std::shared_ptr<Socket> client) const
     if (d_loglevel > WebServer::LogLevel::None) {
       client->getRemote(remote);
     }
-    auto handler = std::make_shared<TCPIOHandler>("", false, client->releaseHandle(), timeout, tlsCtx, time(nullptr));
+    auto handler = std::make_shared<TCPIOHandler>("", false, client->releaseHandle(), timeout, tlsCtx);
 
     PacketBuffer data;
     try {
index 9f92b2ee348ccef8ae82dbabb60ff0e68dfeefb0..848c4b48ccf6096bbc91af28a6e56b05de7dac95 100644 (file)
@@ -417,7 +417,7 @@ try {
     Socket sock(dest.sin4.sin_family, SOCK_STREAM);
     sock.setNonBlocking();
     setTCPNoDelay(sock.getHandle()); // disable NAGLE, which does not play nicely with delayed ACKs
-    TCPIOHandler handler(subjectName, false, sock.releaseHandle(), timeout, tlsCtx, time(nullptr));
+    TCPIOHandler handler(subjectName, false, sock.releaseHandle(), timeout, tlsCtx);
     handler.connect(fastOpen, dest, timeout);
     // we are writing the proxyheader inside the TLS connection. Is that right?
     if (proxyheader.size() > 0 && handler.write(proxyheader.data(), proxyheader.size(), timeout) != proxyheader.size()) {
index a97c465e6c0ddb377c4f109835db71f10315a8dd..88f0dc724be7d098a022e4446db507a5d6f53496 100644 (file)
@@ -233,7 +233,7 @@ class TCPIOHandler
 public:
   enum class Type : uint8_t { Client, Server };
 
-  TCPIOHandler(const std::string& host, bool hostIsAddr, int socket, const struct timeval& timeout, std::shared_ptr<TLSCtx> ctx, time_t /* now */): d_socket(socket)
+  TCPIOHandler(const std::string& host, bool hostIsAddr, int socket, const struct timeval& timeout, std::shared_ptr<TLSCtx> ctx): d_socket(socket)
   {
     if (ctx) {
       d_conn = ctx->getClientConnection(host, hostIsAddr, d_socket, timeout);