From: Fred Morcos Date: Wed, 15 Feb 2023 15:15:18 +0000 (+0100) Subject: Cleanup TCPIOHandler constructor X-Git-Tag: dnsdist-1.8.0-rc1~3^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1152079dc0b52bec3f71e124b4a31d6a18fd2f1d;p=thirdparty%2Fpdns.git Cleanup TCPIOHandler constructor --- diff --git a/pdns/dnsdistdist/dnsdist-discovery.cc b/pdns/dnsdistdist/dnsdist-discovery.cc index c042fa52f9..9d267ecded 100644 --- a/pdns/dnsdistdist/dnsdist-discovery.cc +++ b/pdns/dnsdistdist/dnsdist-discovery.cc @@ -367,8 +367,7 @@ static bool checkBackendUsability(std::shared_ptr& ds) sock.bind(ds->d_config.sourceAddr); } - time_t now = time(nullptr); - auto handler = std::make_unique(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(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; } diff --git a/pdns/dnsdistdist/dnsdist-healthchecks.cc b/pdns/dnsdistdist/dnsdist-healthchecks.cc index 3f8555f35b..4a52052276 100644 --- a/pdns/dnsdistdist/dnsdist-healthchecks.cc +++ b/pdns/dnsdistdist/dnsdist-healthchecks.cc @@ -360,7 +360,7 @@ bool queueHealthCheck(std::unique_ptr& mplexer, const std::shared } else { time_t now = time(nullptr); - data->d_tcpHandler = std::make_unique(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(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(*mplexer, data->d_tcpHandler->getDescriptor()); if (ds->d_tlsCtx) { try { diff --git a/pdns/dnsdistdist/dnsdist-tcp-downstream.cc b/pdns/dnsdistdist/dnsdist-tcp-downstream.cc index a6ab7002f2..6c6fcf2229 100644 --- a/pdns/dnsdistdist/dnsdist-tcp-downstream.cc +++ b/pdns/dnsdistdist/dnsdist-tcp-downstream.cc @@ -103,7 +103,7 @@ bool ConnectionToBackend::reconnect() socket.setNonBlocking(); gettimeofday(&d_connectionStartTime, nullptr); - auto handler = std::make_unique(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(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); } diff --git a/pdns/recursordist/lwres.cc b/pdns/recursordist/lwres.cc index 40e44fc659..b63f53f9bd 100644 --- a/pdns/recursordist/lwres.cc +++ b/pdns/recursordist/lwres.cc @@ -314,7 +314,7 @@ static bool tcpconnect(const struct timeval& now, const ComboAddress& ip, TCPOut dnsOverTLS = false; } } - connection.d_handler = std::make_shared(nsName, false, s.releaseHandle(), timeout, tlsCtx, now.tv_sec); + connection.d_handler = std::make_shared(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); diff --git a/pdns/recursordist/rec-carbon.cc b/pdns/recursordist/rec-carbon.cc index 43b1df9570..d0f77742cc 100644 --- a/pdns/recursordist/rec-carbon.cc +++ b/pdns/recursordist/rec-carbon.cc @@ -49,7 +49,7 @@ void doCarbonDump(void*) { g_networkTimeoutMsec / 1000, static_cast(g_networkTimeoutMsec) % 1000 * 1000 }; - auto handler = std::make_shared("", false, s.releaseHandle(), timeout, tlsCtx, time(nullptr)); + auto handler = std::make_shared("", 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()) { diff --git a/pdns/recursordist/ws-recursor.cc b/pdns/recursordist/ws-recursor.cc index 21ddd01ee9..c5ca3ccc66 100644 --- a/pdns/recursordist/ws-recursor.cc +++ b/pdns/recursordist/ws-recursor.cc @@ -1408,7 +1408,7 @@ void AsyncWebServer::serveConnection(std::shared_ptr client) const if (d_loglevel > WebServer::LogLevel::None) { client->getRemote(remote); } - auto handler = std::make_shared("", false, client->releaseHandle(), timeout, tlsCtx, time(nullptr)); + auto handler = std::make_shared("", false, client->releaseHandle(), timeout, tlsCtx); PacketBuffer data; try { diff --git a/pdns/sdig.cc b/pdns/sdig.cc index 9f92b2ee34..848c4b48cc 100644 --- a/pdns/sdig.cc +++ b/pdns/sdig.cc @@ -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()) { diff --git a/pdns/tcpiohandler.hh b/pdns/tcpiohandler.hh index a97c465e6c..88f0dc724b 100644 --- a/pdns/tcpiohandler.hh +++ b/pdns/tcpiohandler.hh @@ -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 ctx, time_t /* now */): d_socket(socket) + TCPIOHandler(const std::string& host, bool hostIsAddr, int socket, const struct timeval& timeout, std::shared_ptr ctx): d_socket(socket) { if (ctx) { d_conn = ctx->getClientConnection(host, hostIsAddr, d_socket, timeout);