Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ACE_Logging_Strategy::handle_timeout returning -1 without releasing ACE_Log_Msg lock #2259

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions ACE/ace/Logging_Strategy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,16 +433,20 @@ 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<ACE_Log_Msg> guard (*this->log_msg_);
if (!guard.locked ())
ACELIB_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("Cannot acquire lock!\n")),
-1);

// Close the current ostream.
#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.
if (output_file)
{
ACE_OS::fclose (output_file);
this->log_msg_->msg_ostream (nullptr);
}
#else
ofstream *output_file =
(ofstream *) this->log_msg_->msg_ostream ();
Expand Down Expand Up @@ -470,9 +474,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;
}
}
Expand Down Expand Up @@ -563,9 +564,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;
Expand Down
Loading