diff options
author | cbeaulac <cbeaulac@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2010-04-18 18:04:15 +0000 |
---|---|---|
committer | cbeaulac <cbeaulac@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2010-04-18 18:04:15 +0000 |
commit | c9c007c0f6acaf001ddc1521b965004b08c7f8b7 (patch) | |
tree | 5408f45128ab3f991a3a62dd2163d63c3e794c93 | |
parent | 99eb3343c0e1a6be81325052187adb90823a87d9 (diff) | |
download | ATCD-c9c007c0f6acaf001ddc1521b965004b08c7f8b7.tar.gz |
Sun Apr 18 18:04:11 UTC 2010 Chad Beaulac <chad@objectivesolutions.com>
* ace/Service_Types.cpp
ACE_Module_Type::fini was reverted to original code from trunk. It calls fini on
the reader and writer tasks, closes and deletes the Module, and
returns ACE_Service_Type_Impl::fini()
ACE_Stream_Type::fini was modified to not call ACE_Module_Type::fini as this will
results in a double delete when ACE_Service_Repository::fini is called.
ACE_Stream_Type::remove(module_name) was modified to not call
ACE_Module_Type::fini as this will results in a double delete
when ACE_Service_Repository::fini is called also.
* ace/Service_Repository.cpp
Modified ASR::fini to iterate over the service_array_ twice. ACE_Service_Type::fini is called
on all ACE_Stream_Type and ACE_Service_Object_Type instances first. Then, fini is called on
all ACE_Modules_Type instances. All calls to fini are done in the order the services appear
in the ASR::service_array_ except for the grouping described here. The calls to
ACE_Module_Type::fini must be done last because ACE_Stream_Type::fini accesses the Modules
so they must not be deleted from a call to ACE_Module_Type::fini before that.
I'll create a patch for ACE Bugzilla #3334 after this commit.
-rw-r--r-- | ace/Service_Repository.cpp | 6 | ||||
-rw-r--r-- | ace/Service_Types.cpp | 25 |
2 files changed, 10 insertions, 21 deletions
diff --git a/ace/Service_Repository.cpp b/ace/Service_Repository.cpp index 48bf411784d..c04eeb372b6 100644 --- a/ace/Service_Repository.cpp +++ b/ace/Service_Repository.cpp @@ -113,6 +113,7 @@ ACE_Service_Repository::ACE_Service_Repository (size_t size) ACE_TRACE ("ACE_Service_Repository::ACE_Service_Repository"); } + /// Finalize (call fini() and possibly delete) all the services. int ACE_Service_Repository::fini (void) @@ -130,7 +131,7 @@ ACE_Service_Repository::fini (void) ACE_Service_Type *s = const_cast<ACE_Service_Type *> (this->service_array_[i]); - if (s->type ()->service_type () == ACE_Service_Type::MODULE) + if (s->type ()->service_type () != ACE_Service_Type::MODULE) { #ifndef ACE_NLOGGING if (ACE::debug ()) @@ -164,7 +165,7 @@ ACE_Service_Repository::fini (void) ACE_Service_Type *s = const_cast<ACE_Service_Type *> (this->service_array_[i]); - if (s->type ()->service_type () != ACE_Service_Type::MODULE) + if (s->type ()->service_type () == ACE_Service_Type::MODULE) { #ifndef ACE_NLOGGING if (ACE::debug ()) @@ -194,6 +195,7 @@ ACE_Service_Repository::fini (void) return (retval == 0) ? 0 : -1; } + /// Close down all the services. int ACE_Service_Repository::close (void) diff --git a/ace/Service_Types.cpp b/ace/Service_Types.cpp index e05e2134a8f..5c2c2fae3b7 100644 --- a/ace/Service_Types.cpp +++ b/ace/Service_Types.cpp @@ -244,15 +244,10 @@ ACE_Module_Type::fini (void) const if (writer != 0) writer->fini (); - -#if 0 // Close the module and delete the memory. mod->close (MT_Module::M_DELETE); return ACE_Service_Type_Impl::fini (); - -#endif - return 0; } int @@ -370,20 +365,13 @@ ACE_Stream_Type::fini (void) const void *obj = this->object (); MT_Stream *str = (MT_Stream *) obj; - for (ACE_Module_Type *m = this->head_; m != 0; ) - { - ACE_Module_Type *t = m->link (); + for (ACE_Module_Type *m = this->head_; m != 0;) + { + ACE_Module_Type *t = m->link (); // Final arg is an indication to *not* delete the Module. str->remove (m->name (), - MT_Module::M_DELETE_NONE); - - // Finalize the Module (this may delete it, but we don't really - // care since we don't access it again). - m->fini (); - // This should be done in ACE_Module_Type::fini but that creates - // a double delete problem so we do it here. - delete m; + MT_Module::M_DELETE_NONE); m = t; } str->close (); @@ -420,9 +408,8 @@ ACE_Stream_Type::remove (ACE_Module_Type *mod) MT_Module::M_DELETE_NONE) == -1) result = -1; - // This call may end up deleting m, which is ok since we - // don't access it again! - m->fini (); + // Do not call m->fini (); as this will result in a double delete + // of the ACE_Module_type when ACE_Service_Repository::fini is called } else prev = m; |