From: Remi Gacogne Date: Wed, 16 Sep 2020 09:41:01 +0000 (+0200) Subject: dnsdist: Add 'hasBufferedData' method to TCPIOHandler X-Git-Tag: auth-4.5.0-alpha0~14^2~9 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c1a9629b5cabde881dcf3e3a9810d170ed6d4bf7;p=thirdparty%2Fpdns.git dnsdist: Add 'hasBufferedData' method to TCPIOHandler --- diff --git a/pdns/dnsdist-tcp.cc b/pdns/dnsdist-tcp.cc index f1383a0d09..1da8097268 100644 --- a/pdns/dnsdist-tcp.cc +++ b/pdns/dnsdist-tcp.cc @@ -837,11 +837,14 @@ void IncomingTCPConnectionState::handleTimeout(std::shared_ptrd_state = IncomingTCPConnectionState::State::idle; state->d_ioState->update(IOState::Done, handleIOCallback, state); + +#ifdef DEBUGLOG_ENABLED for (const auto& active : state->d_activeConnectionsToBackend) { for (const auto& conn: active.second) { DEBUGLOG("Connection to "<getName()<<" is "<<(conn->isIdle() ? "idle" : "not idle")); } } +#endif } } diff --git a/pdns/dnsdistdist/tcpiohandler-mplexer.hh b/pdns/dnsdistdist/tcpiohandler-mplexer.hh index 1971a3a152..0b85fe68ae 100644 --- a/pdns/dnsdistdist/tcpiohandler-mplexer.hh +++ b/pdns/dnsdistdist/tcpiohandler-mplexer.hh @@ -5,6 +5,7 @@ #include "tcpiohandler.hh" #if 0 +#define DEBUGLOG_ENABLED #define DEBUGLOG(x) cerr< 0; + } + + return false; + } + void close() override { if (d_conn) { @@ -690,6 +699,15 @@ public: return got; } + bool hasBufferedData() const override + { + if (d_conn) { + return gnutls_record_check_pending(d_conn.get()) > 0; + } + + return false; + } + std::string getServerNameIndication() const override { if (d_conn) { diff --git a/pdns/tcpiohandler.hh b/pdns/tcpiohandler.hh index 5a937368f0..a5e8320898 100644 --- a/pdns/tcpiohandler.hh +++ b/pdns/tcpiohandler.hh @@ -17,6 +17,7 @@ public: virtual size_t write(const void* buffer, size_t bufferSize, unsigned int writeTimeout) = 0; virtual IOState tryWrite(std::vector& buffer, size_t& pos, size_t toWrite) = 0; virtual IOState tryRead(std::vector& buffer, size_t& pos, size_t toRead) = 0; + virtual bool hasBufferedData() const = 0; virtual std::string getServerNameIndication() const = 0; virtual LibsslTLSVersion getTLSVersion() const = 0; virtual bool hasSessionBeenResumed() const = 0; @@ -293,6 +294,14 @@ public: } } + bool hasBufferedData() const + { + if (d_conn) { + return d_conn->hasBufferedData(); + } + return false; + } + std::string getServerNameIndication() const { if (d_conn) {