]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Add 'hasBufferedData' method to TCPIOHandler
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 16 Sep 2020 09:41:01 +0000 (11:41 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 10 Nov 2020 08:52:23 +0000 (09:52 +0100)
pdns/dnsdist-tcp.cc
pdns/dnsdistdist/tcpiohandler-mplexer.hh
pdns/dnsdistdist/tcpiohandler.cc
pdns/tcpiohandler.hh

index f1383a0d09baa56362a9fdb4fa7a3d02e81eca8e..1da80972684f11dafc4e0466f9e4f4d86645a6d5 100644 (file)
@@ -837,11 +837,14 @@ void IncomingTCPConnectionState::handleTimeout(std::shared_ptr<IncomingTCPConnec
     /* we still have some queries in flight, let's just stop reading for now */
     state->d_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 "<<active.first->getName()<<" is "<<(conn->isIdle() ? "idle" : "not idle"));
       }
     }
+#endif
   }
 }
 
index 1971a3a1520cd9b434e66b6940ecb4be3c5bee57..0b85fe68ae3f5c755fdd6217d9dce71d8936f309 100644 (file)
@@ -5,6 +5,7 @@
 #include "tcpiohandler.hh"
 
 #if 0
+#define DEBUGLOG_ENABLED
 #define DEBUGLOG(x) cerr<<x<<endl;
 #else
 #define DEBUGLOG(x)
index b4ea4c96779b7be966dc7ef5e60b7831ec3424a1..c1ff709344e50d134782c559732552c56094c412 100644 (file)
@@ -224,6 +224,15 @@ public:
     return got;
   }
 
+  bool hasBufferedData() const override
+  {
+    if (d_conn) {
+      return SSL_pending(d_conn.get()) > 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) {
index 5a937368f0dd31fe0e545b8159f06c0e7da58e05..a5e83208986e315658865491db69959577d964a6 100644 (file)
@@ -17,6 +17,7 @@ public:
   virtual size_t write(const void* buffer, size_t bufferSize, unsigned int writeTimeout) = 0;
   virtual IOState tryWrite(std::vector<uint8_t>& buffer, size_t& pos, size_t toWrite) = 0;
   virtual IOState tryRead(std::vector<uint8_t>& 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) {