From: Remi Gacogne Date: Fri, 6 Mar 2020 14:17:45 +0000 (+0100) Subject: Remote Logger: Add comments and catch() advised by Otto during review X-Git-Tag: dnsdist-1.5.0-alpha1~20^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=745889e5dda64e6f023b6694b1eb649db3ed23b5;p=thirdparty%2Fpdns.git Remote Logger: Add comments and catch() advised by Otto during review Also remove the now unused d_maxQueuedBytes field. --- diff --git a/pdns/remote_logger.cc b/pdns/remote_logger.cc index 956d06bb19..0197fa8d09 100644 --- a/pdns/remote_logger.cc +++ b/pdns/remote_logger.cc @@ -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 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: "< d_drops{0}; std::atomic d_queued{0}; - uint64_t d_maxQueuedBytes; std::unique_ptr d_socket{nullptr}; uint16_t d_timeout; uint8_t d_reconnectWaitTime;