]> granicus.if.org Git - pdns/commitdiff
implement 'rec_control get tcp-clients' to debug TCP client issue
authorBert Hubert <bert.hubert@netherlabs.nl>
Sun, 30 May 2010 18:18:51 +0000 (18:18 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Sun, 30 May 2010 18:18:51 +0000 (18:18 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1623 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/pdns_recursor.cc
pdns/rec_channel_rec.cc
pdns/syncres.hh

index 7b8191a9d1f1f45d86d207744e7ba60ea2b38bf3..9bedfc3a9c25a42d352bc541ea0ea2cd2727e038 100644 (file)
@@ -446,29 +446,18 @@ static void writePid(void)
 typedef map<ComboAddress, uint32_t, ComboAddress::addressOnlyLessThan> tcpClientCounts_t;
 tcpClientCounts_t __thread* t_tcpClientCounts;
 
-struct TCPConnection
+
+void TCPConnection::closeAndCleanup(int fd, const ComboAddress& remote) 
 {
-  int fd;
-  enum stateenum {BYTE0, BYTE1, GETQUESTION, DONE} state;
-  int qlen;
-  int bytesread;
-  ComboAddress remote;
-  char data[65535];
-  time_t startTime;
-
-  static void closeAndCleanup(int fd, const ComboAddress& remote) 
-  {
-    Utility::closesocket(fd);
-    if(!(*t_tcpClientCounts)[remote]--) 
-      t_tcpClientCounts->erase(remote);
-    s_currentConnections--;
-  }
-  void closeAndCleanup()
-  {
-    closeAndCleanup(fd, remote);
-  }
-  static unsigned int s_currentConnections; //!< total number of current TCP connections
-};
+  Utility::closesocket(fd);
+  if(!(*t_tcpClientCounts)[remote]--) 
+    t_tcpClientCounts->erase(remote);
+  s_currentConnections--;
+}
+void TCPConnection::closeAndCleanup()
+{
+  closeAndCleanup(fd, remote);
+}
 
 unsigned int TCPConnection::s_currentConnections; 
 void handleRunningTCPQuestion(int fd, FDMultiplexer::funcparam_t& var);
index 10760b407640df060c9ef9c7eebde6fb66286e3b..7edc81ffa0101e9d3d4a40e2f3d4af22c9602d7c 100644 (file)
@@ -393,6 +393,7 @@ RecursorControlParser::RecursorControlParser()
   addGetStat("throttled-out", &SyncRes::s_throttledqueries);
   addGetStat("unreachables", &SyncRes::s_unreachables);
   addGetStat("chain-resends", &g_stats.chainResends);
+  addGetStat("tcp-clients", &TCPConnection::s_currentConnections);
 
   addGetStat("edns-ping-matches", &g_stats.ednsPingMatches);
   addGetStat("edns-ping-mismatches", &g_stats.ednsPingMismatches);
index 22645a2c0af4d93c0782445db6e6207d847bb98f..b6b857d141183a42506fc1a8a8ae4dfb8ca016bd 100644 (file)
@@ -478,6 +478,23 @@ struct RecursorStats
   time_t startupTime;
 };
 
+//! represents a running TCP/IP client session
+struct TCPConnection
+{
+  int fd;
+  enum stateenum {BYTE0, BYTE1, GETQUESTION, DONE} state;
+  int qlen;
+  int bytesread;
+  ComboAddress remote;
+  char data[65535];
+  time_t startTime;
+
+  static void closeAndCleanup(int fd, const ComboAddress& remote);
+  void closeAndCleanup();
+  static unsigned int s_currentConnections; //!< total number of current TCP connections
+};
+
+
 struct RemoteKeeper
 {
   typedef vector<ComboAddress> remotes_t;