From: Remi Gacogne Date: Mon, 8 Feb 2021 15:52:45 +0000 (+0100) Subject: dnsdist: Add a bit more output to the TCP states debug log X-Git-Tag: dnsdist-1.6.0-alpha2~11^2~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fb59deccfdaa83677ade6c172a9b2b729a4c8b98;p=thirdparty%2Fpdns.git dnsdist: Add a bit more output to the TCP states debug log --- diff --git a/pdns/dnsdist-tcp.cc b/pdns/dnsdist-tcp.cc index f547a1b1a3..d3e3626e9e 100644 --- a/pdns/dnsdist-tcp.cc +++ b/pdns/dnsdist-tcp.cc @@ -1014,12 +1014,25 @@ static void tcpClientThread(int pipefd) DownstreamConnectionsManager::cleanupClosedTCPConnections(); lastTCPCleanup = now.tv_sec; - /* +#if 0 + /* just to keep things clean in the output, debug only */ + static std::mutex s_lock; + std::lock_guard lck(s_lock); data.mplexer->runForAllWatchedFDs([](bool isRead, int fd, const FDMultiplexer::funcparam_t& param, struct timeval ttd) { - cerr<<"- "<)) { + auto state = boost::any_cast>(param); + cerr<<" - "<toString()<)) { + auto conn = boost::any_cast>(param); + cerr<<" - "<toString()< lastTimeoutScan) { diff --git a/pdns/dnsdistdist/dnsdist-tcp-downstream.hh b/pdns/dnsdistdist/dnsdist-tcp-downstream.hh index 2ce536a8db..46b53a70ac 100644 --- a/pdns/dnsdistdist/dnsdist-tcp-downstream.hh +++ b/pdns/dnsdistdist/dnsdist-tcp-downstream.hh @@ -169,6 +169,13 @@ public: void setProxyProtocolPayloadAdded(bool added); void setProxyProtocolValuesSent(std::unique_ptr>&& proxyProtocolValuesSent); + std::string toString() const + { + ostringstream o; + o << "TCP connection to backend "<<(d_ds ? d_ds->getName() : "empty")<<" over FD "<<(d_socket ? std::to_string(d_socket->getHandle()) : "no socket")<<", state is "<<(int)d_state<<", io state is "<<(d_ioState ? std::to_string((int)d_ioState->getState()) : "empty")<<", queries count is "<getState()) : "empty")<<", queries count is "<, std::deque>> d_activeConnectionsToBackend;