From f44fc4500a4a17c3c8aec2877a6636560ea4827a Mon Sep 17 00:00:00 2001 From: an-tao Date: Fri, 20 Sep 2024 14:16:47 +0800 Subject: [PATCH 1/2] Fix a bug in the dtor of EventLoop --- trantor/net/EventLoop.cc | 3 +-- trantor/utils/AsyncFileLogger.cc | 4 ++-- trantor/utils/Logger.h | 8 ++++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/trantor/net/EventLoop.cc b/trantor/net/EventLoop.cc index 214c9b4c..8db1090a 100644 --- a/trantor/net/EventLoop.cc +++ b/trantor/net/EventLoop.cc @@ -138,7 +138,6 @@ EventLoop::~EventLoop() #endif } - t_loopInThisThread = nullptr; #ifdef __linux__ close(wakeupFd_); #elif defined _WIN32 @@ -256,7 +255,7 @@ void EventLoop::loop() { f(); } - + t_loopInThisThread = nullptr; // Throw the exception from the end if (loopException) { diff --git a/trantor/utils/AsyncFileLogger.cc b/trantor/utils/AsyncFileLogger.cc index 0044c86f..8aa034d6 100755 --- a/trantor/utils/AsyncFileLogger.cc +++ b/trantor/utils/AsyncFileLogger.cc @@ -64,7 +64,7 @@ AsyncFileLogger::~AsyncFileLogger() } while (!writeBuffers_.empty()) { - StringPtr tmpPtr = (StringPtr &&) writeBuffers_.front(); + StringPtr tmpPtr = (StringPtr &&)writeBuffers_.front(); writeBuffers_.pop(); writeLogToFile(tmpPtr); } @@ -162,7 +162,7 @@ void AsyncFileLogger::logThreadFunc() while (!tmpBuffers_.empty()) { - StringPtr tmpPtr = (StringPtr &&) tmpBuffers_.front(); + StringPtr tmpPtr = (StringPtr &&)tmpBuffers_.front(); tmpBuffers_.pop(); writeLogToFile(tmpPtr); tmpPtr->clear(); diff --git a/trantor/utils/Logger.h b/trantor/utils/Logger.h index 705c60b5..16d040aa 100644 --- a/trantor/utils/Logger.h +++ b/trantor/utils/Logger.h @@ -288,8 +288,8 @@ class TRANTOR_EXPORT Logger : public NonCopyable #endif return logLevel; } - static std::function - &outputFunc_() + static std::function & + outputFunc_() { static std::function outputFunc = Logger::defaultOutputFunction; @@ -300,8 +300,8 @@ class TRANTOR_EXPORT Logger : public NonCopyable static std::function flushFunc = Logger::defaultFlushFunction; return flushFunc; } - static std::function - &outputFunc_(size_t index) + static std::function & + outputFunc_(size_t index) { static std::vector< std::function> From e20377f71b835036842af530dd2932ae1e2ee76d Mon Sep 17 00:00:00 2001 From: an-tao Date: Fri, 20 Sep 2024 14:27:49 +0800 Subject: [PATCH 2/2] Lint --- trantor/utils/AsyncFileLogger.cc | 4 ++-- trantor/utils/Logger.h | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/trantor/utils/AsyncFileLogger.cc b/trantor/utils/AsyncFileLogger.cc index 8aa034d6..0044c86f 100755 --- a/trantor/utils/AsyncFileLogger.cc +++ b/trantor/utils/AsyncFileLogger.cc @@ -64,7 +64,7 @@ AsyncFileLogger::~AsyncFileLogger() } while (!writeBuffers_.empty()) { - StringPtr tmpPtr = (StringPtr &&)writeBuffers_.front(); + StringPtr tmpPtr = (StringPtr &&) writeBuffers_.front(); writeBuffers_.pop(); writeLogToFile(tmpPtr); } @@ -162,7 +162,7 @@ void AsyncFileLogger::logThreadFunc() while (!tmpBuffers_.empty()) { - StringPtr tmpPtr = (StringPtr &&)tmpBuffers_.front(); + StringPtr tmpPtr = (StringPtr &&) tmpBuffers_.front(); tmpBuffers_.pop(); writeLogToFile(tmpPtr); tmpPtr->clear(); diff --git a/trantor/utils/Logger.h b/trantor/utils/Logger.h index 16d040aa..705c60b5 100644 --- a/trantor/utils/Logger.h +++ b/trantor/utils/Logger.h @@ -288,8 +288,8 @@ class TRANTOR_EXPORT Logger : public NonCopyable #endif return logLevel; } - static std::function & - outputFunc_() + static std::function + &outputFunc_() { static std::function outputFunc = Logger::defaultOutputFunction; @@ -300,8 +300,8 @@ class TRANTOR_EXPORT Logger : public NonCopyable static std::function flushFunc = Logger::defaultFlushFunction; return flushFunc; } - static std::function & - outputFunc_(size_t index) + static std::function + &outputFunc_(size_t index) { static std::vector< std::function>