diff options
author | vzykov <vzykov@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2010-02-11 12:34:49 +0000 |
---|---|---|
committer | vzykov <vzykov@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2010-02-11 12:34:49 +0000 |
commit | 021829ecdabfa3b1be8afc29d72339c0fd487704 (patch) | |
tree | 1c0a35462fee541faaebbb740e8b9812d1ed3908 /ACE/tests/NonBlocking_Conn_Test.cpp | |
parent | cc356b71b978d4f612dc7fcf8b5f6a3195337d9f (diff) | |
download | ATCD-021829ecdabfa3b1be8afc29d72339c0fd487704.tar.gz |
Thu Feb 11 12:18:24 UTC 2010 Vladimir Zykov <vladimir.zykov@prismtech.com>
* 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.
Diffstat (limited to 'ACE/tests/NonBlocking_Conn_Test.cpp')
-rw-r--r-- | ACE/tests/NonBlocking_Conn_Test.cpp | 30 |
1 files changed, 18 insertions, 12 deletions
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<ACE_SOCK_STREAM, ACE_NULL_SYNCH>::handle_close (handle, - mask); + typedef ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> 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<Svc_Handler, ACE_SOCK_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; |