diff options
author | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-08-22 05:38:30 +0000 |
---|---|---|
committer | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-08-22 05:38:30 +0000 |
commit | 5fcc127eeca45fe711b81af8ea3505df0ec7b482 (patch) | |
tree | 721050a8504705718f5b6e54764f550d0f5b42cc /ace | |
parent | 6fd665d56bc3600177dd74a3bb15eaca7ceb6524 (diff) | |
download | ATCD-5fcc127eeca45fe711b81af8ea3505df0ec7b482.tar.gz |
*** empty log message ***
Diffstat (limited to 'ace')
-rw-r--r-- | ace/Object_Manager.cpp | 7 | ||||
-rw-r--r-- | ace/Service_Config.cpp | 7 | ||||
-rw-r--r-- | ace/Service_Config.h | 4 | ||||
-rw-r--r-- | ace/Service_Object.cpp | 17 | ||||
-rw-r--r-- | ace/Service_Object.h | 6 | ||||
-rw-r--r-- | ace/Service_Repository.cpp | 22 | ||||
-rw-r--r-- | ace/Service_Repository.h | 3 |
7 files changed, 63 insertions, 3 deletions
diff --git a/ace/Object_Manager.cpp b/ace/Object_Manager.cpp index db612ea060f..6c158d3182d 100644 --- a/ace/Object_Manager.cpp +++ b/ace/Object_Manager.cpp @@ -649,6 +649,10 @@ ACE_Object_Manager::~ACE_Object_Manager (void) ACE_Cleanup_Info info; + // Close and possibly delete all service instances in the Service + // Repository. + ACE_Service_Config::fini_svcs (); + // Call all registered cleanup hooks, in reverse order of // registration. while (registered_objects_ && @@ -661,7 +665,8 @@ ACE_Object_Manager::~ACE_Object_Manager (void) (*info.cleanup_hook_) (info.object_, info.param_); } - // Close and delete all ACE library services and singletons. + // Unlink all services in the Service Repository and close/delete + // all ACE library services and singletons. ACE_Service_Config::close (); // Close the main thread's TSS, including its Log_Msg instance. diff --git a/ace/Service_Config.cpp b/ace/Service_Config.cpp index c08f25bf275..bdd131bd1c1 100644 --- a/ace/Service_Config.cpp +++ b/ace/Service_Config.cpp @@ -651,6 +651,13 @@ ACE_Service_Config::close_svcs (void) } int +ACE_Service_Config::fini_svcs (void) +{ + ACE_TRACE ("ACE_Service_Config::fini_svcs"); + return ACE_Service_Repository::instance ()->fini (); +} + +int ACE_Service_Config::close_singletons (void) { ACE_TRACE ("ACE_Service_Config::close_singletons"); diff --git a/ace/Service_Config.h b/ace/Service_Config.h index cdb9d7ff816..1464c42efbb 100644 --- a/ace/Service_Config.h +++ b/ace/Service_Config.h @@ -128,6 +128,10 @@ public: // down. This method calls <close_svcs> and <close_singletons>. // Returns 0. + static int fini_svcs (void); + // Perform user-specified close hooks and possibly delete all of the + // configured services in the <Service_Repository>. + static int close_svcs (void); // Perform user-specified close hooks on all of the configured // services in the <Service_Repository>, then delete the diff --git a/ace/Service_Object.cpp b/ace/Service_Object.cpp index fbe40d6e7b3..41c64599929 100644 --- a/ace/Service_Object.cpp +++ b/ace/Service_Object.cpp @@ -31,7 +31,8 @@ ACE_Service_Type::ACE_Service_Type (const ASYS_TCHAR *n, #endif /* ACE_HAS_MOSTLY_UNICODE_APIS */ type_ (t), handle_ (h), - active_ (active) + active_ (active), + fini_already_called_ (0) { ACE_TRACE ("ACE_Service_Type::ACE_Service_Type"); this->name (n); @@ -40,16 +41,28 @@ ACE_Service_Type::ACE_Service_Type (const ASYS_TCHAR *n, ACE_Service_Type::~ACE_Service_Type (void) { ACE_TRACE ("ACE_Service_Type::~ACE_Service_Type"); - this->type_->fini (); + + if (!fini_already_called_) + this->type_->fini (); + if (this->handle_ != 0) ACE_OS::dlclose ((ACE_SHLIB_HANDLE) this->handle_); + delete [] (ASYS_TCHAR *) this->name_; + #if defined (ACE_HAS_MOSTLY_UNICODE_APIS) delete [] (char *) this->chname_; #endif /* ACE_HAS_MOSTLY_UNICODE_APIS */ } void +ACE_Service_Type::fini (void) +{ + this->type_->fini (); + this->fini_already_called_ = 1; +} + +void ACE_Service_Type::suspend (void) const { ACE_TRACE ("ACE_Service_Type::suspend"); diff --git a/ace/Service_Object.h b/ace/Service_Object.h index 1c030643ddc..ce048e1f200 100644 --- a/ace/Service_Object.h +++ b/ace/Service_Object.h @@ -87,6 +87,9 @@ public: int active (void) const; void active (int); + void fini (void); + // Calls fini() on <type_> + void dump (void) const; // Dump the state of an object. @@ -111,6 +114,9 @@ private: int active_; // 1 if svc is currently active, otherwise 0. + + int fini_already_called_; + // 1 if fini() on <type_> has already been called, otherwise 0. }; class ACE_Export ACE_Service_Object_Ptr diff --git a/ace/Service_Repository.cpp b/ace/Service_Repository.cpp index 5fdea43218d..80e343f6faf 100644 --- a/ace/Service_Repository.cpp +++ b/ace/Service_Repository.cpp @@ -113,6 +113,28 @@ ACE_Service_Repository::ACE_Service_Repository (int size) ACE_ERROR ((LM_ERROR, ASYS_TEXT ("%p\n"), ASYS_TEXT ("ACE_Service_Repository"))); } +// Finalize (call fini() and possibly delete) all the services. + +int +ACE_Service_Repository::fini (void) +{ + ACE_TRACE ("ACE_Service_Repository::close"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + + if (this->service_vector_ != 0) + { + // Make sure to fini the services in the reverse order in which + // they were added. + for (int i = this->current_size_ - 1; i >= 0; i--) + { + ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("finalizing %s\n"), + this->service_vector_[i]->name ())); + ((ACE_Service_Type *)this->service_vector_[i])->fini (); + } + } + return 0; +} + // Close down all the services. int diff --git a/ace/Service_Repository.h b/ace/Service_Repository.h index c620e0ddfe2..a2d040f7400 100644 --- a/ace/Service_Repository.h +++ b/ace/Service_Repository.h @@ -56,6 +56,9 @@ public: ~ACE_Service_Repository (void); // Terminate the repository. + int fini (void); + // Finalize (call fini() and possibly delete) all the services. + int close (void); // Terminate the repository. |