From 021829ecdabfa3b1be8afc29d72339c0fd487704 Mon Sep 17 00:00:00 2001 From: vzykov Date: Thu, 11 Feb 2010 12:34:49 +0000 Subject: Thu Feb 11 12:18:24 UTC 2010 Vladimir Zykov * ace/Connector.cpp: Added a call to remove_reference() for a svc handler owned by non-blocking connection handler during connector's close(). * ace/Svc_Handler.cpp: Removed the code that removes a reference to itself. Svc_Handler doesn't own that reference and thus shouldn't remove it. * tests/Bug_2609_Regression_Test.cpp: * tests/NonBlocking_Conn_Test.h: * tests/Bug_2610_Regression_Test.cpp: * tests/NonBlocking_Conn_Test.cpp: Fixed the tests that implicitly assumed ownership of a reference to a svc handler and didn't free it at the end of the test. * tests/Process_Strategy_Test.cpp: Fixed the test that was broken by my change on 'Mon Feb 8 16:21:06 UTC 2010'. The test incorrectly assumed that close_handle() will not be called for svc handlers in a parent process. --- ACE/tests/NonBlocking_Conn_Test.cpp | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'ACE/tests/NonBlocking_Conn_Test.cpp') diff --git a/ACE/tests/NonBlocking_Conn_Test.cpp b/ACE/tests/NonBlocking_Conn_Test.cpp index 4cad80d5583..e1501dd5a8f 100644 --- a/ACE/tests/NonBlocking_Conn_Test.cpp +++ b/ACE/tests/NonBlocking_Conn_Test.cpp @@ -37,9 +37,10 @@ static int result = 0; Svc_Handler::Svc_Handler (bool is_ref_counted) : status_ (0), - completion_counter_ (0) + completion_counter_ (0), + is_ref_counted_ (is_ref_counted) { - if (is_ref_counted) + if (this->is_ref_counted_) { // Enable reference counting on the event handler. this->reference_counting_policy ().value ( @@ -70,8 +71,21 @@ Svc_Handler::handle_close (ACE_HANDLE handle, ACE_Reactor_Mask mask) *this->status_ = Svc_Handler::Conn_FAILED; (*this->completion_counter_)++; - return ACE_Svc_Handler::handle_close (handle, - mask); + typedef ACE_Svc_Handler super; + + bool const is_ref_counted = this->is_ref_counted_; + + int const res = super::handle_close (handle, + mask); + + if (is_ref_counted) + { + // If we use reference counting then remove reference + // which we own since Svc_Handler creation. + this->remove_reference (); + } + + return res; } typedef ACE_Connector CONNECTOR; @@ -154,14 +168,6 @@ test_connect (ACE_Reactor &reactor, { svc_handlers[i]->close (); } - else if (with_ref_counting && - complete_nonblocking_connections == Svc_Handler::NO) - { - // If we use reference counting and don't wait for connections - // then they can never succeed and we have to remove - // reference manually in order to avoid memory leaks. - svc_handlers[i]->remove_reference (); - } } delete[] svc_handlers; -- cgit v1.2.1