]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Remote Logger: Add comments and catch() advised by Otto during review 8887/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 6 Mar 2020 14:17:45 +0000 (15:17 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 6 Mar 2020 16:11:54 +0000 (17:11 +0100)
Also remove the now unused d_maxQueuedBytes field.

pdns/remote_logger.cc
pdns/remote_logger.hh

index 956d06bb19474dd44890fb20373d0ad357c8dc45..0197fa8d098058fcb34adec5a79d3c962a879116 100644 (file)
@@ -97,7 +97,7 @@ bool CircularWriteBuffer::flush(int fd)
   return true;
 }
 
-RemoteLogger::RemoteLogger(const ComboAddress& remote, uint16_t timeout, uint64_t maxQueuedBytes, uint8_t reconnectWaitTime, bool asyncConnect): d_writer(maxQueuedBytes), d_remote(remote), d_maxQueuedBytes(maxQueuedBytes), d_timeout(timeout), d_reconnectWaitTime(reconnectWaitTime), d_asyncConnect(asyncConnect)
+RemoteLogger::RemoteLogger(const ComboAddress& remote, uint16_t timeout, uint64_t maxQueuedBytes, uint8_t reconnectWaitTime, bool asyncConnect): d_writer(maxQueuedBytes), d_remote(remote), d_timeout(timeout), d_reconnectWaitTime(reconnectWaitTime), d_asyncConnect(asyncConnect)
 {
   if (!d_asyncConnect) {
     reconnect();
@@ -196,6 +196,9 @@ try
         /* we don't want to take the lock while trying to reconnect */
         std::unique_lock<std::mutex> lock(d_mutex);
         if (d_socket) { // check if it is set
+          /* if flush() returns false, it means that we couldn't flush anything yet
+             either because there is nothing to flush, or because the outgoing TCP
+             buffer is full. That's fine by us */
           d_writer.flush(d_socket->getHandle());
         }
         else {
@@ -218,7 +221,10 @@ try
 }
 catch(const std::exception& e)
 {
-  cerr<<"Thead died on: "<<e.what()<<endl;
+  cerr << "Remote Logger's maintenance thead died on: " << e.what() << endl;
+}
+catch(...) {
+  cerr << "Remote Logger's maintenance thead died on unknown exception" << endl;
 }
 
 RemoteLogger::~RemoteLogger()
index af48f6ed66579c5766a95647665a5fb361d05827..70b7af35fdd2b09ac63b58691e49a985e6cbde85 100644 (file)
@@ -105,7 +105,6 @@ private:
   ComboAddress d_remote;
   std::atomic<uint64_t> d_drops{0};
   std::atomic<uint64_t> d_queued{0};
-  uint64_t d_maxQueuedBytes;
   std::unique_ptr<Socket> d_socket{nullptr};
   uint16_t d_timeout;
   uint8_t d_reconnectWaitTime;