Skip to content

Commit

Permalink
Added debug messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
dchapyshev committed Nov 10, 2024
1 parent 77942a8 commit 49551df
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions source/base/net/tcp_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,8 @@ bool TcpChannel::setKeepAlive(bool enable, const Seconds& interval, const Second

if (!enable)
{
LOG(LS_INFO) << "Keep alive disabled";

keep_alive_counter_.clear();

if (keep_alive_timer_)
Expand All @@ -391,6 +393,9 @@ bool TcpChannel::setKeepAlive(bool enable, const Seconds& interval, const Second
}
else
{
LOG(LS_INFO) << "Keep alive enabled (interval=" << interval.count()
<< " timeout=" << timeout.count() << ")";

keep_alive_interval_ = interval;
keep_alive_timeout_ = timeout;

Expand Down Expand Up @@ -989,6 +994,7 @@ void TcpChannel::onReadServiceData(const std::error_code& error_code, size_t byt
largeNumberIncrement(&keep_alive_counter_);

// Restart keep alive timer.
keep_alive_timer_->cancel();
keep_alive_timer_->expires_after(keep_alive_interval_);
keep_alive_timer_->async_wait(
std::bind(&Handler::onKeepAliveInterval, handler_, std::placeholders::_1));
Expand Down Expand Up @@ -1017,6 +1023,7 @@ void TcpChannel::onKeepAliveInterval(const std::error_code& error_code)
LOG(LS_ERROR) << "Keep alive timer error: " << utf16FromLocal8Bit(error_code.message());

// Restarting the timer.
keep_alive_timer_->cancel();
keep_alive_timer_->expires_after(keep_alive_interval_);
keep_alive_timer_->async_wait(
std::bind(&Handler::onKeepAliveInterval, handler_, std::placeholders::_1));
Expand All @@ -1031,6 +1038,7 @@ void TcpChannel::onKeepAliveInterval(const std::error_code& error_code)

// If a response is not received within the specified interval, the connection will be
// terminated.
keep_alive_timer_->cancel();
keep_alive_timer_->expires_after(keep_alive_timeout_);
keep_alive_timer_->async_wait(
std::bind(&Handler::onKeepAliveTimeout, handler_, std::placeholders::_1));
Expand Down

0 comments on commit 49551df

Please sign in to comment.