From e59f217f8de701e9529dcb4c88e98fd34ae1ad0c Mon Sep 17 00:00:00 2001 From: Alexander Tokmakov Date: Fri, 5 Aug 2022 13:33:27 +0200 Subject: [PATCH] add test logs on connection close --- src/Server/TCPHandler.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Server/TCPHandler.cpp b/src/Server/TCPHandler.cpp index 05565063893..16599c378e7 100644 --- a/src/Server/TCPHandler.cpp +++ b/src/Server/TCPHandler.cpp @@ -190,7 +190,10 @@ void TCPHandler::runImpl() /// If we need to shut down, or client disconnects. if (!tcp_server.isOpen() || server.isCancelled() || in->eof()) + { + LOG_TEST(log, "Closing connection (open: {}, cancelled: {}, eof: {})", tcp_server.isOpen(), server.isCancelled(), in->eof()); break; + } Stopwatch watch; state.reset(); @@ -406,6 +409,8 @@ void TCPHandler::runImpl() if (e.code() == ErrorCodes::UNKNOWN_PACKET_FROM_CLIENT) throw; + LOG_TEST(log, "Going to close connection due to exception: {}", e.message()); + /// If there is UNEXPECTED_PACKET_FROM_CLIENT emulate network_error /// to break the loop, but do not throw to send the exception to /// the client. @@ -435,7 +440,7 @@ void TCPHandler::runImpl() // Server should die on std logic errors in debug, like with assert() // or ErrorCodes::LOGICAL_ERROR. This helps catch these errors in // tests. -#ifndef NDEBUG +#ifdef ABORT_ON_LOGICAL_ERROR catch (const std::logic_error & e) { state.io.onException(); @@ -554,14 +559,14 @@ bool TCPHandler::readDataNext() Stopwatch watch(CLOCK_MONOTONIC_COARSE); /// Poll interval should not be greater than receive_timeout - constexpr UInt64 min_timeout_ms = 5000; // 5 ms - UInt64 timeout_ms = std::max(min_timeout_ms, std::min(poll_interval * 1000000, static_cast(receive_timeout.totalMicroseconds()))); + constexpr UInt64 min_timeout_us = 5000; // 5 ms + UInt64 timeout_us = std::max(min_timeout_us, std::min(poll_interval * 1000000, static_cast(receive_timeout.totalMicroseconds()))); bool read_ok = false; /// We are waiting for a packet from the client. Thus, every `POLL_INTERVAL` seconds check whether we need to shut down. while (true) { - if (static_cast(*in).poll(timeout_ms)) + if (static_cast(*in).poll(timeout_us)) { /// If client disconnected. if (in->eof())