summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorharris_s <harris_s@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2004-11-04 23:11:00 +0000
committerharris_s <harris_s@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2004-11-04 23:11:00 +0000
commit632a7974d829a4d503a2f4f7f78eafe21158959d (patch)
tree9fc9b6460b5860e760617707506ba58df0ba0eaf
parentbfb148c57446fa92929b75fc159cf992441af2f1 (diff)
downloadATCD-632a7974d829a4d503a2f4f7f78eafe21158959d.tar.gz
Thu Nov 4 17:06:08 CST 2004 Scott Harris <harris_s@ociweb.com>
-rw-r--r--ChangeLog22
-rw-r--r--tests/Log_Msg_Test.cpp3
-rw-r--r--tests/Test_Output.cpp24
3 files changed, 43 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 993966a5e15..2127a8e8534 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+Thu Nov 4 17:06:08 CST 2004 Scott Harris <harris_s@ociweb.com>
+
+ * test/Test_Output.cpp:
+
+ Fix a bug introduced by a memory leak fix in Logging_Strategy.cpp,
+ Mon Oct 18 21:13:02 2004 Douglas C. Schmidt <schmidt@cs.wustl.edu>
+ , that broke the test/Logging_Strategy_Test on some platforms.
+ The problem is that Test_Output gives its file stream away
+ to ACE_LOG_MSG and then ACE_Logging_Strategry::init destroys the
+ stream but ACE_END_TEST still tries to close and destory it.
+ The solution was to only have Test_Output close/destroy the
+ stream if it has not already be changed in ACE_LOG_MSG.
+
+ * test/Log_Msg_Test.cpp:
+
+ The above change made it so ACE_Test_Output::output_file ()
+ returns the ACE_MSG_LOG stream so it would not return
+ a possibly destroyed stream. Log_Msg_Test had
+ to be changed to save off the message stream when it
+ switched to a different file stream and then back
+ to the original.
+
Thu Nov 4 14:00:50 2004 J.T. Conklin <jtc@acorntoolworks.com>
* ace/QoS/Makefile.am:
diff --git a/tests/Log_Msg_Test.cpp b/tests/Log_Msg_Test.cpp
index daff113d3b4..293e0354589 100644
--- a/tests/Log_Msg_Test.cpp
+++ b/tests/Log_Msg_Test.cpp
@@ -353,6 +353,7 @@ test_ostream (void)
if (myostream.bad ())
return -1;
+ OFSTREAM *old_stream = ace_file_stream::instance ()->output_file ();
// Set the ostream.
ACE_LOG_MSG->msg_ostream (&myostream);
@@ -360,7 +361,7 @@ test_ostream (void)
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("fourth message\n")));
// Set the ostream back to the test's log file.
- ACE_LOG_MSG->msg_ostream (ace_file_stream::instance ()->output_file ());
+ ACE_LOG_MSG->msg_ostream (old_stream);
// Now close the ostream file and check its contents.
myostream.close ();
diff --git a/tests/Test_Output.cpp b/tests/Test_Output.cpp
index adb9e9e8e46..ed0e180faa8 100644
--- a/tests/Test_Output.cpp
+++ b/tests/Test_Output.cpp
@@ -48,6 +48,8 @@ ACE_Test_Output::ACE_Test_Output (void)
ACE_Test_Output::~ACE_Test_Output (void)
{
#if !defined (ACE_LACKS_IOSTREAM_TOTALLY) && !defined (ACE_PSOS)
+ ACE_OSTREAM_TYPE *log_msg_stream = ACE_LOG_MSG->msg_ostream ();
+
ACE_LOG_MSG->msg_ostream (&cerr);
#endif /* ! ACE_LACKS_IOSTREAM_TOTALLY && ! ACE_PSOS */
@@ -55,14 +57,21 @@ ACE_Test_Output::~ACE_Test_Output (void)
ACE_LOG_MSG->set_flags (ACE_Log_Msg::STDERR);
#if !defined (ACE_LACKS_IOSTREAM_TOTALLY) && !defined (ACE_HAS_PHARLAP)
- delete this->output_file_;
+ if (this->output_file_ == log_msg_stream)
+ delete this->output_file_;
+ // else something else changed the stream and hence should
+ // have closed and deleted the output_file_
#endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */
}
OFSTREAM *
ACE_Test_Output::output_file (void)
{
- return this->output_file_;
+ // the output_file_ is given to ACE_LOG_MSG
+ // and something else might destroy and/or change the stream
+ // so return what ACE_LOG_MSG is using.
+ return dynamic_cast<OFSTREAM*>( ACE_LOG_MSG->msg_ostream () );
+ //return this->output_file_;
}
int
@@ -146,7 +155,7 @@ ACE_Test_Output::set_output (const ACE_TCHAR *filename, int append)
this->output_file_ = ACE_OS::fopen (temp, fmode);
# endif /* ACE_LACKS_IOSTREAM_TOTALLY */
- ACE_LOG_MSG->msg_ostream (this->output_file ());
+ ACE_LOG_MSG->msg_ostream (this->output_file_);
#endif /* ACE_HAS_PHARLAP */
ACE_LOG_MSG->clr_flags (ACE_Log_Msg::STDERR | ACE_Log_Msg::LOGGER );
@@ -159,8 +168,13 @@ void
ACE_Test_Output::close (void)
{
#if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
- this->output_file_->flush ();
- this->output_file_->close ();
+ if (this->output_file_ == ACE_LOG_MSG->msg_ostream () )
+ {
+ this->output_file_->flush ();
+ this->output_file_->close ();
+ }
+ // else something else changed the stream and hence should
+ // have closed and deleted the output_file_
#else
ACE_OS::fflush (this->output_file_);
ACE_OS::fclose (this->output_file_);