diff options
-rw-r--r-- | ACE/ACEXML/apps/svcconf/Svcconf_Handler.cpp | 13 | ||||
-rw-r--r-- | ACE/ChangeLog | 30 | ||||
-rw-r--r-- | ACE/ace/Service_Config.h | 12 | ||||
-rw-r--r-- | ACE/ace/Service_Gestalt.cpp | 47 | ||||
-rw-r--r-- | ACE/ace/Service_Gestalt.h | 42 | ||||
-rw-r--r-- | ACE/ace/Service_Gestalt.inl | 6 | ||||
-rw-r--r-- | ACE/ace/Service_Object.cpp | 3 | ||||
-rw-r--r-- | ACE/bin/tao_orb_tests.lst | 1 |
8 files changed, 101 insertions, 53 deletions
diff --git a/ACE/ACEXML/apps/svcconf/Svcconf_Handler.cpp b/ACE/ACEXML/apps/svcconf/Svcconf_Handler.cpp index d592c5f743c..a0986aef0d2 100644 --- a/ACE/ACEXML/apps/svcconf/Svcconf_Handler.cpp +++ b/ACE/ACEXML/apps/svcconf/Svcconf_Handler.cpp @@ -6,6 +6,7 @@ #include "ace/Service_Config.h" #include "ace/Service_Types.h" #include "ace/Service_Repository.h" +#include "ace/Service_Gestalt.h" #include "ace/DLL.h" #include "ace/ARGV.h" #include "ace/Module.h" @@ -60,6 +61,13 @@ ACEXML_Svcconf_Handler::endElement (const ACEXML_Char *, &this->parsed_info_ : &this->stream_info_); + // We must allocate a string here to ensure that the + // name is still available by the time the + // ACE_Service_Type_Dynamic_Guard is destructed. + ACE_TString name = active_info->name (); + ACE_Service_Type_Dynamic_Guard dummy ( + *ACE_Service_Config::current ()->current_service_repository (), + name.c_str ()); ACE_DLL svc_dll; if (svc_dll.open (active_info->path ()) == -1) @@ -147,11 +155,6 @@ ACEXML_Svcconf_Handler::endElement (const ACEXML_Char *, mp->name ())); mp->name (active_info->name ()); } - ACE_Service_Type *stype - = ACE_Service_Config::create_service_type (active_info->name (), - stp, - svc_dll, - active_info->active ()); if (mt->init (args.argc (), args.argv ()) == -1 || this->stream_->push (mt) == -1) diff --git a/ACE/ChangeLog b/ACE/ChangeLog index 5aa6b8164c0..96b57b1846e 100644 --- a/ACE/ChangeLog +++ b/ACE/ChangeLog @@ -1,3 +1,33 @@ +Mon Apr 2 15:02:26 UTC 2007 Chad Elliott <elliott_c@ociweb.com> + + * ace/Service_Object.cpp: + + Removed an unnecessary const_cast of the ACE_DLL data member in + one of the constructors. + + * ace/Service_Config.h: + + Added an ACE_STATIC_SERVICE_DIRECTIVE similar to + ACE_DYNAMIC_SERVICE_DIRECTIVE to ease the testing of processing + single directives with the XML service configurator. + + * ACEXML/apps/svcconf/Svcconf_Handler.cpp: + * ace/Service_Gestalt.h: + * ace/Service_Gestalt.inl: + * ace/Service_Gestalt.cpp: + + Fixed Bug 2677 by moving the ACE_Service_Type_Dynamic_Guard out of + the Service_Gestalt.cpp and into the .h. This guard is then used + in ACEXML_Svcconf_Handler::endElement before loading a shared + library which may insert an entity into the + ACE_Service_Repository. Upon unloading the shared library, + objects will be destroyed in the proper order. Thanks to Lothar + Werzinger <lothar at tradescape dot biz> for reporting this. + + * bin/tao_orb_tests.lst: + + Added Bug_2677_Regression to the list of tests. + Fri Mar 30 14:51:19 UTC 2007 Chad Elliott <elliott_c@ociweb.com> * bin/svcconf-convert.pl: diff --git a/ACE/ace/Service_Config.h b/ACE/ace/Service_Config.h index 6151f8f4cc1..0837fd24eab 100644 --- a/ACE/ace/Service_Config.h +++ b/ACE/ace/Service_Config.h @@ -40,6 +40,12 @@ class ACE_Thread_Manager; class ACE_DLL; #if (ACE_USES_CLASSIC_SVC_CONF == 1) +#define ACE_STATIC_SERVICE_DIRECTIVE(ident, parameters) \ + ACE_LIB_TEXT ("static ") \ + ACE_LIB_TEXT (ident) \ + ACE_LIB_TEXT (" \"") \ + ACE_LIB_TEXT (parameters) \ + ACE_LIB_TEXT ("\"") #define ACE_DYNAMIC_SERVICE_DIRECTIVE(ident, libpathname, objectclass, parameters) \ ACE_LIB_TEXT ("dynamic ") \ ACE_LIB_TEXT (ident) \ @@ -55,6 +61,12 @@ class ACE_DLL; ACE_LIB_TEXT (ident) class ACE_Svc_Conf_Param; #else +#define ACE_STATIC_SERVICE_DIRECTIVE(ident, parameters) \ + ACE_LIB_TEXT ("<ACE_Svc_Conf><static id=\"") \ + ACE_LIB_TEXT (ident) \ + ACE_LIB_TEXT ("\" params=\"") \ + ACE_LIB_TEXT (parameters) \ + ACE_LIB_TEXT ("\"/></ACE_Svc_Conf>") #define ACE_DYNAMIC_SERVICE_DIRECTIVE(ident, libpathname, objectclass, parameters) \ ACE_LIB_TEXT ("<ACE_Svc_Conf><dynamic id=\"") \ ACE_LIB_TEXT (ident) \ diff --git a/ACE/ace/Service_Gestalt.cpp b/ACE/ace/Service_Gestalt.cpp index 76a4abf558b..004f5f2e826 100644 --- a/ACE/ace/Service_Gestalt.cpp +++ b/ACE/ace/Service_Gestalt.cpp @@ -35,49 +35,6 @@ ACE_RCSID (ace, ACE_BEGIN_VERSIONED_NAMESPACE_DECL -/// This is in the implementation file because it depends on the -/// ACE_DLL type, which would be unnecessary to introduuce all over -/// the place, had we declared this in the header file. - -/// @class ACE_Service_Type_Dynamic_Guard -/// -/// @brief A forward service declaration guard. -/// -/// Helps to resolve an issue with hybrid services, i.e. dynamic -/// services, accompanied by static services in the same DLL. Only -/// automatic instances of SDG are supposed to exist. Those are -/// created during (dynamic) service initialization and serve to: -/// -/// (a) Ensure the service we are loading is ordered last in the -/// repository, following any other services it may cause to register, -/// as part of its own registration. This is a common case when -/// loading dynamic services from DLLs - there are often static -/// initializers, which register static services. -/// -/// (b) The SDG instance destructor detects if the dynamic service -/// initialized successfully and "fixes-up" all the newly registered -/// static services to hold a reference to the DLL, from which they -/// have originated. - -class ACE_Service_Type_Dynamic_Guard -{ -public: - ACE_Service_Type_Dynamic_Guard (ACE_Service_Repository &r, - ACE_TCHAR const *name); - - ~ACE_Service_Type_Dynamic_Guard (void); - -private: - const ACE_DLL dummy_dll_; - ACE_Service_Repository & repo_; - size_t repo_begin_; - ACE_TCHAR const * const name_; - ACE_Service_Type const * dummy_; -# if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) - ACE_Guard< ACE_Recursive_Thread_Mutex > repo_monitor_; -#endif -}; - ACE_Service_Type_Dynamic_Guard::ACE_Service_Type_Dynamic_Guard (ACE_Service_Repository &r, const ACE_TCHAR *name) : repo_ (r) @@ -107,8 +64,8 @@ ACE_Service_Type_Dynamic_Guard::ACE_Service_Type_Dynamic_Guard 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 + ACE_DLL (), // ... bogus ACE_DLL + 0)); // ... no type_impl ACE_ASSERT (this->dummy_ != 0); // No memory? diff --git a/ACE/ace/Service_Gestalt.h b/ACE/ace/Service_Gestalt.h index 319ce7a0864..8a9949bd190 100644 --- a/ACE/ace/Service_Gestalt.h +++ b/ACE/ace/Service_Gestalt.h @@ -312,6 +312,9 @@ public: const ACE_Static_Svc_Descriptor *assd_; }; + /// Get the current ACE_Service_Repository held by this object. + ACE_Service_Repository* current_service_repository (void); + protected: /** @@ -447,6 +450,45 @@ protected: }; /* class ACE_Service_Gestalt */ +/** + * @class ACE_Service_Type_Dynamic_Guard + * + * @brief A forward service declaration guard. + * + * Helps to resolve an issue with hybrid services, i.e. dynamic + * services, accompanied by static services in the same DLL. Only + * automatic instances of SDG are supposed to exist. Those are + * created during (dynamic) service initialization and serve to: + * + * (a) Ensure the service we are loading is ordered last in the + * repository, following any other services it may cause to register, + * as part of its own registration. This is a common case when + * loading dynamic services from DLLs - there are often static + * initializers, which register static services. + * + * (b) The SDG instance destructor detects if the dynamic service + * initialized successfully and "fixes-up" all the newly registered + * static services to hold a reference to the DLL, from which they + * have originated. + */ +class ACE_Service_Type_Dynamic_Guard +{ +public: + ACE_Service_Type_Dynamic_Guard (ACE_Service_Repository &r, + ACE_TCHAR const *name); + + ~ACE_Service_Type_Dynamic_Guard (void); + +private: + ACE_Service_Repository & repo_; + size_t repo_begin_; + ACE_TCHAR const * const name_; + ACE_Service_Type const * dummy_; +# if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) + ACE_Guard< ACE_Recursive_Thread_Mutex > repo_monitor_; +#endif +}; + ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Service_Gestalt.inl b/ACE/ace/Service_Gestalt.inl index db9e9ad6d80..2f1c88e7db3 100644 --- a/ACE/ace/Service_Gestalt.inl +++ b/ACE/ace/Service_Gestalt.inl @@ -65,6 +65,10 @@ ACE_Service_Gestalt::find (const ACE_TCHAR name[], return 0; } - +ACE_INLINE ACE_Service_Repository* +ACE_Service_Gestalt::current_service_repository (void) +{ + return this->repo_; +} ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Service_Object.cpp b/ACE/ace/Service_Object.cpp index 6e3d5bd9efc..cc2a1605a39 100644 --- a/ACE/ace/Service_Object.cpp +++ b/ACE/ace/Service_Object.cpp @@ -71,8 +71,7 @@ ACE_Service_Type::ACE_Service_Type (const ACE_TCHAR *n, fini_already_called_ (0) { ACE_TRACE ("ACE_Service_Type::ACE_Service_Type"); - ACE_DLL &dll = const_cast<ACE_DLL &> (this->dll_); - dll.set_handle (handle); + this->dll_.set_handle (handle); this->name (n); } diff --git a/ACE/bin/tao_orb_tests.lst b/ACE/bin/tao_orb_tests.lst index 9df5e4d43c3..49ea45fc19c 100644 --- a/ACE/bin/tao_orb_tests.lst +++ b/ACE/bin/tao_orb_tests.lst @@ -79,6 +79,7 @@ TAO/tests/Bug_2593_Regression/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MI TAO/tests/Bug_2595_Regression/run_test.pl: TAO/tests/Bug_2654_Regression/run_test.pl: !ST !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO TAO/tests/Bug_2669_Regression/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO +TAO/tests/Bug_2677_Regression/run_test.pl: !STATIC TAO/tests/Bug_2683_Regression/run_test.pl: TAO/tests/Bug_2735_Regression/run_test.pl: TAO/tests/Bug_2792_Regression/run_test.pl: |