diff options
author | iliyan <iliyan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2007-02-16 13:48:13 +0000 |
---|---|---|
committer | iliyan <iliyan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2007-02-16 13:48:13 +0000 |
commit | 462ed48b6a9c7621a6487bf0fd7718611cf057ef (patch) | |
tree | 65134368ec6647628de2cdb2fef41e4f1e7b9068 | |
parent | c4f11ad2eb50ac7fc84a16b60f5210f045c97e51 (diff) | |
download | ATCD-462ed48b6a9c7621a6487bf0fd7718611cf057ef.tar.gz |
ChangeLogTag: Fri Feb 16 13:38:04 UTC 2007 Iliyan Jeliazkov <iliyan@ociweb.com>
-rw-r--r-- | ACE/ChangeLog | 15 | ||||
-rw-r--r-- | ACE/ace/Dynamic_Service_Base.cpp | 8 | ||||
-rw-r--r-- | ACE/ace/Dynamic_Service_Dependency.cpp | 2 | ||||
-rw-r--r-- | ACE/ace/Service_Config.cpp | 4 | ||||
-rw-r--r-- | ACE/ace/Service_Config.h | 2 | ||||
-rw-r--r-- | ACE/ace/Service_Gestalt.cpp | 259 | ||||
-rw-r--r-- | ACE/ace/Service_Gestalt.h | 10 | ||||
-rw-r--r-- | ACE/ace/Service_Gestalt.inl | 19 |
8 files changed, 147 insertions, 172 deletions
diff --git a/ACE/ChangeLog b/ACE/ChangeLog index 9f15e3dc8b0..deb9e160d90 100644 --- a/ACE/ChangeLog +++ b/ACE/ChangeLog @@ -1,3 +1,18 @@ +Fri Feb 16 13:38:04 UTC 2007 Iliyan Jeliazkov <iliyan@ociweb.com> + + * ace/Dynamic_Service_Base.cpp: + * ace/Dynamic_Service_Dependency.cpp: + * ace/Service_Config.h: + * ace/Service_Config.inl: + * ace/Service_Config.cpp: + * ace/Service_Gestalt.h: + * ace/Service_Gestalt.inl: + * ace/Service_Gestalt.cpp: + + Reverting my changes since "Tue Feb 13 15:35:54 UTC 2007" as it + has been causing problems, in particular with borland and + no-threads builds. + Fri Feb 16 12:47:03 UTC 2007 Steve Huston <shuston@riverace.com> * ace/Service_Config.cpp (global): Removed the ACE_INLINE qualifier diff --git a/ACE/ace/Dynamic_Service_Base.cpp b/ACE/ace/Dynamic_Service_Base.cpp index 94400ddffdc..cc5e9114871 100644 --- a/ACE/ace/Dynamic_Service_Base.cpp +++ b/ACE/ace/Dynamic_Service_Base.cpp @@ -32,7 +32,7 @@ void * ACE_Dynamic_Service_Base::instance (const ACE_TCHAR *name, bool no_global) { ACE_TRACE ("ACE_Dynamic_Service_Base::instance"); - return instance (ACE_Service_Config::instance (), name, no_global); + return instance (ACE_Service_Config::current (), name, no_global); } @@ -40,7 +40,7 @@ void * ACE_Dynamic_Service_Base::instance (const ACE_TCHAR *name) { ACE_TRACE ("ACE_Dynamic_Service_Base::instance"); - return instance (ACE_Service_Config::instance (), name, false); + return instance (ACE_Service_Config::current (), name, false); } @@ -49,14 +49,14 @@ ACE_Dynamic_Service_Base::instance (const ACE_TCHAR *name) const ACE_Service_Type * ACE_Dynamic_Service_Base::find_i (const ACE_Service_Gestalt* &repo, const ACE_TCHAR *name, - bool local_only) + bool no_global) { ACE_TRACE ("ACE_Dynamic_Service_Base::find_i"); const ACE_Service_Type *svc_rec = 0; ACE_Service_Gestalt* global = ACE_Service_Config::global (); - for ( ; (repo->find (name, &svc_rec) == -1) && !local_only; repo = global) + for ( ; (repo->find (name, &svc_rec) == -1) && !no_global; repo = global) { // Check the static repo, too if different if (repo == global) diff --git a/ACE/ace/Dynamic_Service_Dependency.cpp b/ACE/ace/Dynamic_Service_Dependency.cpp index a2c25c2e6bf..f2a9b45d61c 100644 --- a/ACE/ace/Dynamic_Service_Dependency.cpp +++ b/ACE/ace/Dynamic_Service_Dependency.cpp @@ -14,7 +14,7 @@ ACE_RCSID (ace, ACE_Dynamic_Service_Dependency::ACE_Dynamic_Service_Dependency (const ACE_TCHAR *principal) { - this->init (ACE_Service_Config::instance (), principal); + this->init (ACE_Service_Config::current (), principal); } ACE_Dynamic_Service_Dependency::ACE_Dynamic_Service_Dependency (const ACE_Service_Gestalt *cfg, diff --git a/ACE/ace/Service_Config.cpp b/ACE/ace/Service_Config.cpp index 7a2d958d854..94cc1cfb9c0 100644 --- a/ACE/ace/Service_Config.cpp +++ b/ACE/ace/Service_Config.cpp @@ -336,9 +336,9 @@ ACE_Service_Config::static_svcs (void) return ACE_Service_Config::instance (); } -/// Return the global configuration instance. Always returns the same +/// Return the global configuration instance. Allways returns the same /// instance -ACE_Service_Config * +ACE_INLINE ACE_Service_Config * ACE_Service_Config::global (void) { return ACE_SERVICE_CONFIG_SINGLETON::instance (); diff --git a/ACE/ace/Service_Config.h b/ACE/ace/Service_Config.h index 423e174d6fe..f6c7e5f0975 100644 --- a/ACE/ace/Service_Config.h +++ b/ACE/ace/Service_Config.h @@ -144,7 +144,7 @@ public: * * Another facet of ACE_Service_Config is that for a given thread, * it provides access to its current, process-global - * ACE_Service_Gestalt instance through its current() method. + * ACE_Service_Gestalt instance through its curent() method. * * @note The signal_handler_ static member is allocated by the * ACE_Object_Manager. The ACE_Service_Config constructor diff --git a/ACE/ace/Service_Gestalt.cpp b/ACE/ace/Service_Gestalt.cpp index ea7d96dbd2b..8b6eeb9fc97 100644 --- a/ACE/ace/Service_Gestalt.cpp +++ b/ACE/ace/Service_Gestalt.cpp @@ -1,20 +1,34 @@ // $Id$ -#include "ace/OS_NS_sys_stat.h" #include "ace/Svc_Conf.h" #include "ace/Get_Opt.h" #include "ace/ARGV.h" +#include "ace/Malloc.h" #include "ace/Service_Manager.h" #include "ace/Service_Types.h" -#include "ace/Service_Repository.h" +#include "ace/Containers.h" +#include "ace/Auto_Ptr.h" +#include "ace/Reactor.h" +#include "ace/Thread_Manager.h" +#include "ace/DLL.h" #include "ace/XML_Svc_Conf.h" +#include "ace/SString.h" #ifndef ACE_LACKS_UNIX_SIGNALS # include "ace/Signal.h" #endif /* !ACE_LACKS_UNIX_SIGNALS */ +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_time.h" +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_sys_stat.h" + +#include "ace/TSS_T.h" #include "ace/Service_Gestalt.h" +#include "ace/Svc_Conf_Param.h" + ACE_RCSID (ace, Service_Gestalt, "$Id$") @@ -90,180 +104,118 @@ ACE_Service_Type_Dynamic_Guard::ACE_Service_Type_Dynamic_Guard #endif { ACE_ASSERT (this->name_ != 0); // No name? - - // Heap-allocate the forward declaration because that's where the - // repository exects them to be ... - ACE_NEW_NORETURN (this->dummy_, + ACE_NEW_NORETURN (this->dummy_, // Allocate the forward declaration ... ACE_Service_Type (this->name_, // ... use the same name 0, // ... inactive this->dummy_dll_, // ... bogus ACE_DLL 0)); // ... no type_impl -#ifndef ACE_NLOGGING + ACE_ASSERT (this->dummy_ != 0); // No memory? + if(ACE::debug ()) ACE_DEBUG ((LM_DEBUG, - ACE_LIB_TEXT ("ACE (%P|%t) Service_Type_Dynamic_Guard") - ACE_LIB_TEXT (":<ctor> - new fwd decl") - ACE_LIB_TEXT (", repo[%d]=%@, name=%s, type=%@") - ACE_LIB_TEXT (", impl=%@, object=%@, active=%d\n"), - this->repo_begin_, - &this->repo_, - this->name_, - this->dummy_, + ACE_LIB_TEXT ("ACE (%P|%t) STDG::<ctor>, repo=%@ [%d], ") + ACE_LIB_TEXT ("name=%s, type=%@, impl=%@, object=%@, active=%d - inserting dummy forward\n"), + &this->repo_, this->repo_begin_, this->name_, this->dummy_, this->dummy_->type (), - (this->dummy_->type () != 0) - ? this->dummy_->type ()->object () - : 0, + (this->dummy_->type () != 0) ? this->dummy_->type ()->object () : 0, this->dummy_->active ())); -#endif /* ACE_NLOGGING */ - - // No memory ... - if (this->dummy_ == 0) - return; // Note that the dummy_'s memory may be deallocated between invoking - // the ctor and dtor. For example, if the real dynamic service is + // the ctor and dtor, if the expected ("real") dynamic service is // inserted in the repository. See how this affects the destructor's // behavior, below. - if (this->repo_.insert (this->dummy_) != 0) - { - delete this->dummy_; - this->dummy_ = 0; - }; + this->repo_.insert (this->dummy_); } /// Destructor + ACE_Service_Type_Dynamic_Guard::~ACE_Service_Type_Dynamic_Guard (void) { - // Lookup without ignoring suspended services. Making sure not to - // ignore any inactive services, since those may be forward + const ACE_Service_Type *tmp = 0; + + // Lookup without ignoring suspended services. Making sure + // not to ignore any inactive services, since those may be forward // declarations size_t slot = 0; - const ACE_Service_Type *tmp = 0; int const ret = this->repo_.find_i (this->name_, slot, &tmp, false); // We inserted it (as inactive), so we expect to find it, right? if (ret < 0 && ret != -2) { -#ifndef ACE_NLOGGING if (ACE::debug ()) ACE_ERROR ((LM_WARNING, - ACE_LIB_TEXT ("ACE (%P|%t) Service_Type_Dynamic_Guard") - ACE_LIB_TEXT (":<dtor> - find %s failed, returns %d/%d\n"), + ACE_LIB_TEXT ("ACE (%P|%t) STDG::<dtor> - Failed (%d) to find %s\n"), + ret, this->name_)); + return; + } + + if (tmp != 0 && tmp->type () != 0) + { + // Something has registered a proper (non-forward-decl) service with + // the same name as our dummy. + + if(ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_LIB_TEXT ("ACE (%P|%t) STDG::<dtor>, repo=%@, name=%s - updating [%d - %d]\n"), + &this->repo_, this->name_, - ret, - errno)); -#endif /* ACE_NLOGGING */ + this->repo_begin_, + this->repo_.current_size ())); + + // Relocate any static services. If any have been registered in + // the context of this guard, those really aren't static + // services because their code is in the DLL's code segment + this->repo_.relocate_i (this->repo_begin_, this->repo_.current_size (), tmp->dll()); + + // The ACE_Service_Gestalt::insert() modifies the memory for the + // original ACE_Service_Type instance. It deletes our dummy + // instance when replacing it with the actual implementation, so + // we are hereby simply giving up ownership. + this->dummy_ = 0; - delete this->dummy_; - } + if(ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_LIB_TEXT ("ACE (%P|%t) STDG::<dtor>, repo=%@ [%d], ") + ACE_LIB_TEXT ("name=%s, type=%@, impl=%@, object=%@, active=%d - loaded\n"), + &this->repo_, this->repo_begin_, this->name_, tmp, tmp->type (), + (tmp->type () != 0) ? tmp->type ()->object () : 0, + tmp->active ())); + } else - { - // So we found a service with the same name - if (tmp != 0 && tmp->type () != 0) - { - // If something did register a proper (non-forward-decl) - // service with the same name as our dummy, then it has - // acquired the ownership of the instance dummy_ points to. -#ifndef ACE_NLOGGING - if(ACE::debug ()) - ACE_DEBUG ((LM_DEBUG, - ACE_LIB_TEXT ("ACE (%P|%t) Service_Type_Dynamic_Guard") - ACE_LIB_TEXT (":<dtor> - relocating [%d-%d]") - ACE_LIB_TEXT (", repo=%@, name=%s\n"), - this->repo_begin_, - this->repo_.current_size (), - &this->repo_, - this->name_)); -#endif /* ACE_NLOGGING */ - - // Relocate any related static services. If any have been - // registered in the context of this guard, those really - // aren't static services because their code is in the DLL's - // code segment - this->repo_.relocate_i (this->repo_begin_, - this->repo_.current_size (), - tmp->dll()); - - // The ACE_Service_Gestalt::insert() modifies the memory for - // the original ACE_Service_Type instance. It will delete our - // dummy instance when replacing it with the actual - // implementation. We are hereby simply giving up ownership of - // something that no longer exists. - this->dummy_ = 0; - -#ifndef ACE_NLOGGING - if(ACE::debug ()) - ACE_DEBUG ((LM_DEBUG, - ACE_LIB_TEXT ("ACE (%P|%t) Service_Type_Dynamic_Guard") - ACE_LIB_TEXT (":<dtor> - done loading of %s") - ACE_LIB_TEXT (", repo[%d]=%@, type=%@, impl=%@") - ACE_LIB_TEXT (", object=%@, active=%d\n"), - this->name_, - this->repo_begin_, - &this->repo_, - tmp, - tmp->type (), - (tmp->type () != 0) ? tmp->type ()->object () : 0, - tmp->active ())); -#endif /* ACE_NLOGGING */ - } - else - { -#ifndef ACE_NLOGGING - if(ACE::debug ()) - ACE_DEBUG ((LM_DEBUG, - ACE_LIB_TEXT ("ACE (%P|%t) Service_Type_Dynamic_Guard") - ACE_LIB_TEXT (":<dtor> - removing fwd decl for %s") - ACE_LIB_TEXT (", repo=%@, type=%@, impl=%@") - ACE_LIB_TEXT (", object=%@, active=%d\n"), - this->name_, - &this->repo_, - this->dummy_, - this->dummy_->type (), - (this->dummy_->type () != 0) - ? this->dummy_->type ()->object () - : 0, + { + if(ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_LIB_TEXT ("ACE (%P|%t) STDG::<dtor>, repo=%@, ") + ACE_LIB_TEXT ("name=%s, type=%@, impl=%@, object=%@, active=%d - removing dummy forward\n"), + &this->repo_, this->name_, this->dummy_, this->dummy_->type (), + (this->dummy_->type () != 0) ? this->dummy_->type ()->object () : 0, + this->dummy_->active ())); + + // The (dummy) forward declaration is still there and is + // the same, which means that no actual declaration was + // provided inside the guarded scope. Therefore, the forward + // declaration is no longer necessary. + if (this->repo_.remove_i (this->name_, + const_cast< ACE_Service_Type**> (&this->dummy_)) == 0) + { + // If it is a dummy then deleting it while holding the repo lock is okay. There will be no + // call to service object's fini() and no possibility for deadlocks. + delete this->dummy_; + } + else + { + ACE_ERROR ((LM_WARNING, + ACE_LIB_TEXT ("ACE (%P|%t) STDG::<dtor>, repo=%@, name=%s, ") + ACE_LIB_TEXT ("type=%@, impl=%@, object=%@, active=%d - dummy remove failed\n"), + &this->repo_, this->name_, this->dummy_, this->dummy_->type (), + (this->dummy_->type () != 0) ? this->dummy_->type ()->object () : 0, this->dummy_->active ())); -#endif /* ACE_NLOGGING */ - - // The (dummy) forward declaration is still there and is the - // same, which means that no actual declaration was provided - // inside the guarded scope. Therefore, the forward - // declaration is no longer necessary. - if (this->repo_.remove_i (this->name_, - const_cast< ACE_Service_Type**> - (&this->dummy_)) == 0) - { - // If it is a dummy then deleting it while holding the - // repo lock is okay. There will be no call to service - // object's fini() and no possibility for deadlocks. - delete this->dummy_; - } - else - { -#ifndef ACE_NLOGGING - ACE_ERROR ((LM_WARNING, - ACE_LIB_TEXT ("ACE (%P|%t) Service_Type_Dynamic_Guard") - ACE_LIB_TEXT (":<dtor> - failed to remove fwd decl %s") - ACE_LIB_TEXT (", repo=%@, type=%@, impl=%@") - ACE_LIB_TEXT (", object=%@, active=%d: -1/%d\n"), - this->name_, - &this->repo_, - this->dummy_, - this->dummy_->type (), - (this->dummy_->type () != 0) - ? this->dummy_->type ()->object () - : 0, - this->dummy_->active (), - errno)); -#endif /* ACE_NLOGGING */ - } - } - } + } + } - // Clean up and bail ... + // Clean up this->dummy_ = 0; } @@ -304,7 +256,7 @@ ACE_Service_Gestalt::~ACE_Service_Gestalt (void) ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("ACE (%P|%t) SG::dtor - this=%@, pss = %@\n"), this, this->processed_static_svcs_)); -#endif /* ACE_NLOGGING */ +#endif if (this->processed_static_svcs_ && !this->processed_static_svcs_->is_empty()) @@ -400,24 +352,6 @@ ACE_Service_Gestalt::load_static_svcs (void) -/// Searches for a service object declaration in the local repo, only - -int -ACE_Service_Gestalt::find (const ACE_TCHAR name[], - const ACE_Service_Type **srp, - int ignore_suspended) const -{ - // Closing the gestalt will have disassociated it from the - // repository. If the repository used to be owned by the gestalt, it - // will also have been destroyed - so just check for repo_ before - // doing anything with it. - if (this->repo_ != 0) - return this->repo_->find (name, srp, ignore_suspended); - - return 0; -} - - /// Find a static service descriptor by name int @@ -598,6 +532,7 @@ ACE_Service_Gestalt::initialize (const ACE_TCHAR *svc_name, const ACE_Service_Type *srp = 0; for (int i = 0; this->find (svc_name, &srp) == -1 && i < 2; i++) + // if (this->repo_->find (svc_name, &srp) == -1) { const ACE_Static_Svc_Descriptor *assd = ACE_Service_Config::global()->find_processed_static_svc(svc_name); diff --git a/ACE/ace/Service_Gestalt.h b/ACE/ace/Service_Gestalt.h index 9cc4b079793..a5d656a53a5 100644 --- a/ACE/ace/Service_Gestalt.h +++ b/ACE/ace/Service_Gestalt.h @@ -14,14 +14,21 @@ #define ACE_SERVICE_GESTALT_H #include /**/ "ace/pre.h" + #include /**/ "ace/config-all.h" +#include "ace/Default_Constants.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ +#include "ace/Auto_Ptr.h" #include "ace/SString.h" #include "ace/Unbounded_Queue.h" +#include "ace/Service_Repository.h" +#include "ace/Singleton.h" +#include "ace/OS_NS_signal.h" +#include "ace/Synch_Traits.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -35,8 +42,7 @@ class ACE_DLL; class ACE_Static_Svc_Descriptor; class ACE_Svc_Conf_Param; -class ACE_Service_Type; -class ACE_Service_Repository; +class ACE_Service_Gestalt; /** * @class ACE_Service_Gestalt diff --git a/ACE/ace/Service_Gestalt.inl b/ACE/ace/Service_Gestalt.inl index c6258728c65..db9e9ad6d80 100644 --- a/ACE/ace/Service_Gestalt.inl +++ b/ACE/ace/Service_Gestalt.inl @@ -48,4 +48,23 @@ ACE_Service_Gestalt::open (int argc, ignore_debug_flag); } +/// Searches for a service object declaration in the local repo, only + +ACE_INLINE int +ACE_Service_Gestalt::find (const ACE_TCHAR name[], + const ACE_Service_Type **srp, + int ignore_suspended) const +{ + // Closing the gestalt will have disassociated it from the + // repository. If the repository used to be owned by the gestalt, it + // will also have been destroyed - so just check for repo_ before + // doing anything with it. + if (this->repo_ != 0) + return this->repo_->find (name, srp, ignore_suspended); + + return 0; +} + + + ACE_END_VERSIONED_NAMESPACE_DECL |