From d7c15e6b90ee1113d65bc621a11c093c3d01ac22 Mon Sep 17 00:00:00 2001 From: coryan Date: Tue, 6 Mar 2007 02:16:54 +0000 Subject: Tue Mar 6 02:07:43 UTC 2007 Carlos O'Ryan --- ACE/ChangeLog | 13 +++++++++++++ ACE/ace/Select_Reactor_Base.cpp | 6 +++--- ACE/tests/Bug_2820_Regression_Test.cpp | 33 ++++++++++++++++++++++++--------- 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/ACE/ChangeLog b/ACE/ChangeLog index b4d3394f0c0..5d18277aeef 100644 --- a/ACE/ChangeLog +++ b/ACE/ChangeLog @@ -1,3 +1,16 @@ +Tue Mar 6 02:07:43 UTC 2007 Carlos O'Ryan + + * ace/Select_Reactor_Base.cpp: + Fixed bugs in loop to extract event handlers from notification + pipe. + + * tests/Bug_2820_Regression_Test.cpp: + Fixed several problems in the test: + - The Event_Handler called on the Reactor on its destructor, but + by then the reactor was already destroyed. + - Improved debugging messages. + - Fixed memory management problems, valgrind is happy now. + Mon Mar 5 18:01:36 UTC 2007 Carlos O'Ryan * ace/Notification_Queue.cpp: diff --git a/ACE/ace/Select_Reactor_Base.cpp b/ACE/ace/Select_Reactor_Base.cpp index 73412037931..35896b41c09 100644 --- a/ACE/ace/Select_Reactor_Base.cpp +++ b/ACE/ace/Select_Reactor_Base.cpp @@ -646,9 +646,9 @@ ACE_Select_Reactor_Notify::close (void) // "stored" in the pipe had their reference counts increased. We // need to decrease them before closing the pipe.... ACE_Notification_Buffer b; - for (int r = 0; - r = read_notify_pipe(notification_pipe_.read_handle(), b); - r != -1) + for (int r = read_notify_pipe(notification_pipe_.read_handle(), b); + r > 0; + r = read_notify_pipe(notification_pipe_.read_handle(), b)) { if (b.eh_ == 0) continue; b.eh_->remove_reference(); diff --git a/ACE/tests/Bug_2820_Regression_Test.cpp b/ACE/tests/Bug_2820_Regression_Test.cpp index 02026185780..9c61d4bde87 100644 --- a/ACE/tests/Bug_2820_Regression_Test.cpp +++ b/ACE/tests/Bug_2820_Regression_Test.cpp @@ -36,6 +36,9 @@ public: /// Constructor Simple_Handler(ACE_Reactor * reactor); + /// Destructor + ~Simple_Handler(); + /// Receive (and ignore) the notifications virtual int handle_exception(ACE_HANDLE); }; @@ -76,6 +79,9 @@ run_main (int, ACE_TCHAR *[]) reactor.reset(); + // Reset the reactor in the event handler, since it is gone.p + v->reactor(0); + ACE_Event_Handler::Reference_Count pos_release_count = v->add_reference(); @@ -90,18 +96,22 @@ run_main (int, ACE_TCHAR *[]) pre_notify_count, pos_release_count)); } - // Remove a reference for each time we explicitly increased it, - // minus one time because the _var will take care of that. + ACE_DEBUG ((LM_INFO, + ACE_TEXT("Ref count results. pre_notify refcount=%d,") + ACE_TEXT(" pos_notify=%d, pos_delete=%d\n"), + pre_notify_count, pos_notify_count, pos_release_count)); + + // Remove a reference for each time we explicitly increased it. v->remove_reference(); v->remove_reference(); + ACE_Event_Handler::Reference_Count pos_remove_count = + v->remove_reference(); - if (result == 0) - { - ACE_DEBUG ((LM_INFO, - ACE_TEXT("Test passed. pre_notify refcount=%d,") - ACE_TEXT(" pos_notify=%d, pos_delete=%d\n"), - pre_notify_count, pos_notify_count, pos_release_count)); - } + ACE_DEBUG ((LM_INFO, + ACE_TEXT("Ref count results. pre_notify refcount=%d,") + ACE_TEXT(" pos_notify=%d, pos_delete=%d, pos_remove=%d\n"), + pre_notify_count, pos_notify_count, pos_release_count, + pos_remove_count)); ACE_END_TEST; @@ -119,6 +129,11 @@ Simple_Handler( ACE_Event_Handler::Reference_Counting_Policy::ENABLED); } +Simple_Handler:: +~Simple_Handler() +{ +} + int Simple_Handler:: handle_exception(ACE_HANDLE) { -- cgit v1.2.1