diff options
author | jeliazkov_i <jeliazkov_i@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2006-07-18 19:19:21 +0000 |
---|---|---|
committer | jeliazkov_i <jeliazkov_i@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2006-07-18 19:19:21 +0000 |
commit | c5bdc743b5a47c255daf5dd14a54634644b48116 (patch) | |
tree | 9426209fea0eaab0dfbf167cc0ca1504a3bf121c | |
parent | e476cf522cee8be1b9c7867d491a66d1e39faa2c (diff) | |
download | ATCD-c5bdc743b5a47c255daf5dd14a54634644b48116.tar.gz |
ChangeLogTag: Tue Jul 18 19:17:54 UTC 2006 Iliyan Jeliazkov <iliyan@ociweb.com>
-rw-r--r-- | ChangeLog | 39 | ||||
-rw-r--r-- | ace/DLL_Manager.cpp | 73 | ||||
-rw-r--r-- | ace/Parse_Node.cpp | 71 | ||||
-rw-r--r-- | ace/Parse_Node.h | 38 | ||||
-rw-r--r-- | ace/Service_Config.h | 6 | ||||
-rw-r--r-- | ace/Service_Gestalt.cpp | 75 | ||||
-rw-r--r-- | ace/Service_Gestalt.h | 89 |
7 files changed, 232 insertions, 159 deletions
diff --git a/ChangeLog b/ChangeLog index 96a1cf6174f..f386d0de5df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,42 @@ +Tue Jul 18 19:17:54 UTC 2006 Iliyan Jeliazkov <iliyan@ociweb.com> + + This change is in response to bug#2602. It fixes a problem with + trying to use XML as the service configuration file format. The + change also includes additional comments and in-line + documentation on the new ability to use local service + repositories. + + * ace/DLL_Manager.cpp: + + Updated the debugging output of DLL_Handle::open() to be able to + see _why_ a DLL open failed. For example, the errno message is + 'not found' in a case where one tries to open library A, which + in turn depends on library B, but B is missing. This change + allows one to see the underlying cause for the error + (via DLL_Handle::error(), if ACE_DEBUG=2, or greater is + present). + + * ace/Parse_Node.h: + * ace/Parse_Node.cpp: + + Moving the ACE_Service_Type_Factory here, from + Service_Config.{h,cpp} This class is only needed when + ACE_USES_CLASSIC_SVC_CONF is 1, i.e. when ACE is using the + non-XML configuration file format. Therefore, moving it to + Parse_Node.{h,cpp} causes it to compile only if needed. + + * ace/Service_Config.h: + + Removed the static get_xml_svc_conf() method, as it already has + the required implementation in the base class. + + * ace/Service_Gestalt.h: + * ace/Service_Gestalt.cpp: + + Moved the ACE_Service_Type_Factory class to Parse_Node.{h,cpp}. + Updated the documentation with a more clear description of the + class responsibilities. Corrected minor omissions. + Tue Jul 18 18:12:17 UTC 2006 Douglas C. Schmidt <schmidt@dre.vanderbilt.edu> * ACE-INSTALL.html: Updated the description of how to build diff --git a/ace/DLL_Manager.cpp b/ace/DLL_Manager.cpp index fbdc550d94b..43316612845 100644 --- a/ace/DLL_Manager.cpp +++ b/ace/DLL_Manager.cpp @@ -121,16 +121,23 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name, ACE_TString *name = 0; while (name_iter.next (name)) { - if (ACE::debug ()) - ACE_DEBUG ((LM_DEBUG, - ACE_LIB_TEXT ("(%P|%t) ACE_DLL_Handle::open: ") - ACE_LIB_TEXT ("calling dlopen on ") - ACE_LIB_TEXT ("\"%s\"\n"), name->c_str ())); - // The ACE_SHLIB_HANDLE object is obtained. this->handle_ = ACE_OS::dlopen (name->c_str (), open_mode); + if (ACE::debug () > 1) + { + ACE_DEBUG ((LM_DEBUG, + ACE_LIB_TEXT ("ACE (%P|%t) DLL_Handle::open ") + ACE_LIB_TEXT ("(\"%s\", 0x%x) -> %s: %s\n"), + name->c_str (), + open_mode, + ACE_LIB_TEXT ((this->handle_ != ACE_SHLIB_INVALID_HANDLE) + ? "succeeded" + : "failed"), + this->error()->c_str())); + } + if (this->handle_ != ACE_SHLIB_INVALID_HANDLE) // Good one? break; @@ -140,11 +147,11 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name, // mask it. // @TODO: If we've found our DLL _and_ it's // broken, should we continue at all? - if (ACE::debug () && (errno != 0) && (errno != ENOENT)) + if ((errno != 0) && (errno != ENOENT) && ACE::debug ()) ACE_ERROR ((LM_ERROR, - ACE_LIB_TEXT ("(%P|%t) ACE_DLL_Handle::open: ") - ACE_LIB_TEXT ("Attempt to open \'%s\' failed ") - ACE_LIB_TEXT ("(%d): %s\n"), + ACE_LIB_TEXT ("ACE (%P|%t) DLL_Handle::open ") + ACE_LIB_TEXT ("(\'%s\') failed, errno=") + ACE_LIB_TEXT ("%d: %s\n"), name->c_str (), errno, this->error ()->c_str ())); @@ -163,11 +170,18 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name, ACE_OS::strcat (aix_pathname, ACE_LIB_TEXT ("(shr.o)")); open_mode |= RTLD_MEMBER; - if (ACE::debug ()) - ACE_DEBUG ((LM_DEBUG, - ACE_LIB_TEXT ("(%P|%t) ACE_DLL_Handle::open: ") - ACE_LIB_TEXT ("calling dlopen on ") - ACE_LIB_TEXT ("\"%s\"\n"), aix_pathname)); + if (ACE::debug () > 1) + { + ACE_DEBUG ((LM_DEBUG, + ACE_LIB_TEXT ("ACE (%P|%t) DLL_Handle::open ") + ACE_LIB_TEXT ("(\"%s\", 0x%x) -> %s: %s\n"), + aix_pathname, + open_mode, + ACE_LIB_TEXT ((this->handle_ != ACE_SHLIB_INVALID_HANDLE) + ? "succeeded" + : "failed"), + this->error()->c_str())); + } this->handle_ = ACE_OS::dlopen (aix_pathname, open_mode); if (this->handle_ != ACE_SHLIB_INVALID_HANDLE) @@ -181,9 +195,9 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name, // should we continue at all? if (ACE::debug () && (errno != 0) && (errno != ENOENT)) ACE_ERROR ((LM_ERROR, - ACE_LIB_TEXT ("(%P|%t) ACE_DLL_Handle::open: ") - ACE_LIB_TEXT ("Attempt to open \'%s\' failed") - ACE_LIB_TEXT (" (%d): %s\n"), + ACE_LIB_TEXT ("ACE (%P|%t) DLL_Handle::open ") + ACE_LIB_TEXT ("(\'%s\') failed, errno=") + ACE_LIB_TEXT ("%d: %s\n"), name->c_str (), errno, this->error ()->c_str ())); @@ -198,9 +212,8 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name, { if (ACE::debug ()) ACE_ERROR ((LM_ERROR, - ACE_LIB_TEXT ("(%P|%t) DLL_Handle::open: ") - ACE_LIB_TEXT ("Invalid handle while ") - ACE_LIB_TEXT ("opening DLL \"%s\": %s\n"), + ACE_LIB_TEXT ("ACE (%P|%t) DLL_Handle::open (\"%s\"): ") + ACE_LIB_TEXT ("Invalid handle error: %s\n"), this->dll_name_, this->error ()->c_str ())); @@ -539,32 +552,32 @@ ACE_DLL_Manager::open_dll (const ACE_TCHAR *dll_name, ACE_DLL_Handle, 0); - dll_handle = temp_handle; + dll_handle = temp_handle; } } if (dll_handle) { if (dll_handle->open (dll_name, open_mode, handle) != 0) - { - // Error while openind dll. Free temp handle + { + // Error while openind dll. Free temp handle if (ACE::debug ()) ACE_ERROR ((LM_ERROR, ACE_LIB_TEXT ("ACE_DLL_Manager::open_dll: Could not ") ACE_LIB_TEXT ("open dll %s.\n"), dll_name)); - delete temp_handle; + delete temp_handle; return 0; } - + // Add the handle to the vector only if the dll is successfully // opened. if (temp_handle != NULL) - { - this->handle_vector_[this->current_size_] = dll_handle; + { + this->handle_vector_[this->current_size_] = dll_handle; this->current_size_++; - } + } } return dll_handle; @@ -730,7 +743,7 @@ ACE_DLL_Manager::unload_dll (ACE_DLL_Handle *dll_handle, int force_unload) else { if (ACE::debug ()) - ACE_ERROR ((LM_ERROR, + ACE_ERROR ((LM_ERROR, ACE_LIB_TEXT ("ACE_DLL_Manager::unload_dll called with ") ACE_LIB_TEXT ("null pointer.\n"))); diff --git a/ace/Parse_Node.cpp b/ace/Parse_Node.cpp index eabbd2765a3..c3b194499d4 100644 --- a/ace/Parse_Node.cpp +++ b/ace/Parse_Node.cpp @@ -756,6 +756,77 @@ ACE_Static_Function_Node::~ACE_Static_Function_Node (void) delete[] const_cast<ACE_TCHAR *> (this->function_name_); } +ACE_ALLOC_HOOK_DEFINE (ACE_Service_Type_Factory) + +ACE_Service_Type_Factory::ACE_Service_Type_Factory (ACE_TCHAR const *name, + int type, + ACE_Location_Node *location, + int active) + : name_ (name) + , type_ (type) + , location_ (location) + , is_active_ (active) +{ +} + + +ACE_Service_Type_Factory::~ACE_Service_Type_Factory (void) +{ +} + + +ACE_Service_Type * +ACE_Service_Type_Factory::make_service_type (ACE_Service_Gestalt *cfg) const +{ + ACE_TRACE ("ACE_Service_Type_Factory::make_service_type"); + + u_int flags = ACE_Service_Type::DELETE_THIS + | (this->location_->dispose () == 0 ? 0 : ACE_Service_Type::DELETE_OBJ); + + ACE_Service_Object_Exterminator gobbler = 0; + + int yyerrno = 0; + void *sym = this->location_->symbol (cfg, yyerrno, &gobbler); + + if (sym != 0) + { + ACE_Service_Type_Impl *stp + = ACE_Service_Config::create_service_type_impl (this->name (), + this->type_, + sym, + flags, + gobbler); + if (stp == 0) + ++yyerrno; + + ACE_Service_Type *tmp = 0; + ACE_NEW_RETURN (tmp, + ACE_Service_Type (this->name (), + stp, + this->location_->dll (), + this->is_active_), + 0); + return tmp; + } + else + { +#ifndef ACE_NLOGGING + ACE_ERROR ((LM_ERROR, + ACE_LIB_TEXT ("(%P|%t) Unable to find service \'%s\'\n"), + this->name ())); +#endif + ++yyerrno; + return 0; + } +} + +ACE_TCHAR const* +ACE_Service_Type_Factory::name (void) const +{ + return name_.c_str (); +} + + ACE_END_VERSIONED_NAMESPACE_DECL #endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */ diff --git a/ace/Parse_Node.h b/ace/Parse_Node.h index 64c0706db75..c22dbb86f59 100644 --- a/ace/Parse_Node.h +++ b/ace/Parse_Node.h @@ -476,6 +476,44 @@ private: ACE_UNIMPLEMENTED_FUNC (ACE_Static_Function_Node& operator= (const ACE_Static_Function_Node&)) }; +// A helper class used to safely register dynamic services, which may contains +// subordinate static services. It is used to capture the necessary data during +// the parsing, but perform the actuall instantiation later. +class ACE_Service_Type_Factory +{ +public: + ACE_Service_Type_Factory (ACE_TCHAR const *name, + int type, + ACE_Location_Node *location, + int active); + + ~ACE_Service_Type_Factory (void); + + ACE_Service_Type *make_service_type (ACE_Service_Gestalt *pcfg) const; + + ACE_TCHAR const* name (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + + /** + * Not implemented to enforce no copying + */ + ACE_UNIMPLEMENTED_FUNC + (ACE_Service_Type_Factory(const ACE_Service_Type_Factory&)) + + ACE_UNIMPLEMENTED_FUNC + (ACE_Service_Type_Factory& operator=(const ACE_Service_Type_Factory&)) + +private: + ACE_TString name_; + int type_; + ACE_Auto_Ptr<ACE_Location_Node> location_; + int is_active_; +}; + ACE_END_VERSIONED_NAMESPACE_DECL #endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */ diff --git a/ace/Service_Config.h b/ace/Service_Config.h index bc89a5d1c93..a4dc1377efd 100644 --- a/ace/Service_Config.h +++ b/ace/Service_Config.h @@ -127,7 +127,7 @@ public: * @class ACE_Service_Config * * @brief Supplies common server operations for dynamic and static - * configuration of services. + * configuration of service. * * The ACE_Service_Config uses the Monostate pattern. Therefore, * you can only have one of these instantiated per-process. It @@ -521,10 +521,6 @@ protected: /// and process_directive() both call. Returns the number of errors /// that occurred. static int process_directives_i (ACE_Svc_Conf_Param *param); -#else - /// Helper function to dynamically link in the XML Service Configurator - /// parser. - static ACE_XML_Svc_Conf *get_xml_svc_conf (ACE_DLL &d); #endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */ /// Become a daemon. diff --git a/ace/Service_Gestalt.cpp b/ace/Service_Gestalt.cpp index 25db903a3c3..53fe3a52a8e 100644 --- a/ace/Service_Gestalt.cpp +++ b/ace/Service_Gestalt.cpp @@ -386,77 +386,6 @@ ACE_Service_Gestalt::dump (void) const -ACE_ALLOC_HOOK_DEFINE (ACE_Service_Type_Factory) - -ACE_Service_Type_Factory::ACE_Service_Type_Factory (ACE_TCHAR const *name, - int type, - ACE_Location_Node *location, - int active) - : name_ (name) - , type_ (type) - , location_ (location) - , is_active_ (active) -{ -} - - -ACE_Service_Type_Factory::~ACE_Service_Type_Factory (void) -{ -} - - -ACE_Service_Type * -ACE_Service_Type_Factory::make_service_type (ACE_Service_Gestalt *cfg) const -{ - ACE_TRACE ("ACE_Service_Type_Factory::make_service_type"); - - u_int flags = ACE_Service_Type::DELETE_THIS - | (this->location_->dispose () == 0 ? 0 : ACE_Service_Type::DELETE_OBJ); - - ACE_Service_Object_Exterminator gobbler = 0; - - int yyerrno = 0; - void *sym = this->location_->symbol (cfg, yyerrno, &gobbler); - - if (sym != 0) - { - ACE_Service_Type_Impl *stp - = ACE_Service_Config::create_service_type_impl (this->name (), - this->type_, - sym, - flags, - gobbler); - if (stp == 0) - ++yyerrno; - - ACE_Service_Type *tmp = 0; - ACE_NEW_RETURN (tmp, - ACE_Service_Type (this->name (), - stp, - this->location_->dll (), - this->is_active_), - 0); - return tmp; - } - else - { -#ifndef ACE_NLOGGING - ACE_ERROR ((LM_ERROR, - ACE_LIB_TEXT ("(%P|%t) Unable to find service \'%s\'\n"), - this->name ())); -#endif - ++yyerrno; - return 0; - } -} - -ACE_TCHAR const* -ACE_Service_Type_Factory::name (void) const -{ - return name_.c_str (); -} - - /// int @@ -523,6 +452,7 @@ ACE_Service_Gestalt::initialize (const ACE_TCHAR *svc_name, } +#if (ACE_USES_CLASSIC_SVC_CONF == 1) int ACE_Service_Gestalt::initialize (const ACE_Service_Type_Factory *stf, const ACE_TCHAR *parameters) @@ -610,6 +540,7 @@ ACE_Service_Gestalt::initialize (const ACE_Service_Type_Factory *stf, return -1; } +#endif /* (ACE_USES_CLASSIC_SVC_CONF == 1) */ // Dynamically link the shared object file and retrieve a pointer to @@ -928,7 +859,7 @@ ACE_Service_Gestalt::process_file (const ACE_TCHAR file[]) ACE_DLL dll; auto_ptr<ACE_XML_Svc_Conf> - xml_svc_conf (ACE_Service_Config::get_xml_svc_conf (dll)); + xml_svc_conf (this->get_xml_svc_conf (dll)); if (xml_svc_conf.get () == 0) return -1; diff --git a/ace/Service_Gestalt.h b/ace/Service_Gestalt.h index b36c6443330..7b772b51f6a 100644 --- a/ace/Service_Gestalt.h +++ b/ace/Service_Gestalt.h @@ -32,10 +32,16 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL +#if (ACE_USES_CLASSIC_SVC_CONF == 1) class ACE_Service_Type_Factory; +class ACE_Location_Node; +#else +class ACE_XML_Svc_Conf; +class ACE_DLL; +#endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */ + class ACE_Static_Svc_Descriptor; class ACE_Svc_Conf_Param; - class ACE_Service_Gestalt; /** @@ -43,6 +49,21 @@ class ACE_Service_Gestalt; * * @brief Supplies common server operations for dynamic and static * configuration of services. + * + * The Gestalt embodies the concept of configuration context. On one + * hand, it is a flat namespace, where names correspond to a Service + * Object instance. A Gestalt owns the Service Repository instance, + * which in turn owns the Service Object instances. + * + * Another aspect of a Gestalt is its responsibility for + * record-keeping and accounting for the meta-data, necessary for + * locating, removing or instantiating a service. + * + * A repository underlies an instance of a gestalt and its lifetime + * may or may not be bounded by the lifetime of the gestalt, that owns + * it. This feature is important for the derived classes and the + * Service Config in particular. + */ class ACE_Export ACE_Service_Gestalt { @@ -194,10 +215,10 @@ public: /** * Handle the command-line options intended for the - * <ACE_Service_Config>. Note that <argv[0]> is assumed to be the + * <ACE_Service_Gestalt>. Note that <argv[0]> is assumed to be the * program name. + * * The arguments that are valid in a call to this method are - * - '-b' Option to indicate that we should be a daemon * - '-d' Turn on debugging mode * - '-f' Option to read in the list of svc.conf file names * - '-k' Option to read a wide string where in the logger output can @@ -227,6 +248,8 @@ public: int insert (ACE_Static_Svc_Descriptor *stsd); // = Utility methods. + +#if (ACE_USES_CLASSIC_SVC_CONF == 1) /// Dynamically link the shared object file and retrieve a pointer to /// the designated shared object in this file. Also account for the /// possiblity to have static services registered when loading the DLL, by @@ -235,18 +258,20 @@ public: /// problems. int initialize (const ACE_Service_Type_Factory *, const ACE_TCHAR *parameters); +#endif /* (ACE_USES_CLASSIC_SVC_CONF == 1) */ // Dynamically link the shared object file and retrieve a pointer to // the designated shared object in this file. // @obsolete - // @note This is error-prone in the presense of dynamic - // services with their own static services. This method will allow those - // static services to register *before* the dynamic service that owns them. - // Upon finalization of the static services the process may crash, because - // the dynamic service's DLL may have been already released, together with - // the memory in which the static services reside. - // It may not crash, for instance, when the first static service to register - // is the same as the dynamic service being loaded. You should be so lucky! + // @note This is error-prone in the presense of dynamic services, + // which in turn initialize their own static services. This method + // will allow those static services to register *before* the dynamic + // service that owns them. Upon finalization of the static services + // the process will typically crash, because the dynamic service's + // DLL may have been already released, together with the memory in + // which the static services reside. It may not crash, for + // instance, when the first static service to register is the same + // as the dynamic service being loaded. You should be so lucky! int initialize (const ACE_Service_Type *, const ACE_TCHAR *parameters); @@ -335,7 +360,7 @@ protected: #else /// Helper function to dynamically link in the XML Service Configurator /// parser. - ACE_XML_Svc_Conf *get_xml_svc_conf (ACE_DLL &d); + ACE_XML_Svc_Conf* get_xml_svc_conf (ACE_DLL &d); #endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */ // Dynamically link the shared object file and retrieve a pointer to @@ -414,46 +439,6 @@ protected: }; /* class ACE_Service_Gestalt */ -class ACE_Location_Node; - -// A helper class used to safely register dynamic services, which may contains -// subordinate static services. It is used to capture the necessary data during -// the parsing, but perform the actuall instantiation later. -class ACE_Service_Type_Factory -{ -public: - ACE_Service_Type_Factory (ACE_TCHAR const *name, - int type, - ACE_Location_Node *location, - int active); - - ~ACE_Service_Type_Factory (void); - - ACE_Service_Type *make_service_type (ACE_Service_Gestalt *pcfg) const; - - ACE_TCHAR const* name (void) const; - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -private: - - /** - * Not implemented to enforce no copying - */ - ACE_UNIMPLEMENTED_FUNC - (ACE_Service_Type_Factory(const ACE_Service_Type_Factory&)) - - ACE_UNIMPLEMENTED_FUNC - (ACE_Service_Type_Factory& operator=(const ACE_Service_Type_Factory&)) - -private: - ACE_TString name_; - int type_; - ACE_Auto_Ptr<ACE_Location_Node> location_; - int is_active_; -}; - ACE_END_VERSIONED_NAMESPACE_DECL |