From 9dd8a78341c51e21542d0f066506fc52e6343be8 Mon Sep 17 00:00:00 2001 From: Like Ma Date: Thu, 18 Jul 2024 22:46:23 +0800 Subject: [PATCH] Fix ACE_Logging_Strategy::handle_timeout returning -1 without releasing ACE_Log_Msg lock --- ACE/ace/Logging_Strategy.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/ACE/ace/Logging_Strategy.cpp b/ACE/ace/Logging_Strategy.cpp index 7b3335e39fa83..164c4d455ffe1 100644 --- a/ACE/ace/Logging_Strategy.cpp +++ b/ACE/ace/Logging_Strategy.cpp @@ -433,7 +433,8 @@ ACE_Logging_Strategy::handle_timeout (const ACE_Time_Value &, #endif /* ACE_LACKS_IOSTREAM_TOTALLY */ { // Lock out any other logging. - if (this->log_msg_->acquire ()) + ACE_Guard guard (*this->log_msg_); + if (!guard.locked ()) ACELIB_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Cannot acquire lock!\n")), -1); @@ -442,7 +443,7 @@ ACE_Logging_Strategy::handle_timeout (const ACE_Time_Value &, #if defined (ACE_LACKS_IOSTREAM_TOTALLY) FILE *output_file = (FILE *) this->log_msg_->msg_ostream (); ACE_OS::fclose (output_file); - // We'll call msg_ostream() modifier later. + this->log_msg_->msg_ostream (0); #else ofstream *output_file = (ofstream *) this->log_msg_->msg_ostream (); @@ -470,9 +471,6 @@ ACE_Logging_Strategy::handle_timeout (const ACE_Time_Value &, output_file->open (ACE_TEXT_ALWAYS_CHAR (this->filename_), ios::out); #endif /* ACE_LACKS_IOSTREAM_TOTALLY */ - - // Release the lock previously acquired. - this->log_msg_->release (); return 0; } } @@ -563,9 +561,6 @@ ACE_Logging_Strategy::handle_timeout (const ACE_Time_Value &, output_file->open (ACE_TEXT_ALWAYS_CHAR (this->filename_), ios::out); #endif /* ACE_LACKS_IOSTREAM_TOTALLY */ - - // Release the lock previously acquired. - this->log_msg_->release (); } return 0;