diff options
author | iliyan <iliyan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2008-04-07 15:23:38 +0000 |
---|---|---|
committer | iliyan <iliyan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2008-04-07 15:23:38 +0000 |
commit | d1375fcf05be0d9fbc496c724b71ee86fac19366 (patch) | |
tree | e51a0cdbf29da340245b808ec48a9c954727183f | |
parent | e65a30b50ba9bf034a22656d9cb15cad948001b7 (diff) | |
download | ATCD-d1375fcf05be0d9fbc496c724b71ee86fac19366.tar.gz |
ChangeLogTag: Mon Apr 7 15:21:38 UTC 2008 Iliyan Jeliazkov <iliyan@ociweb.com>
-rw-r--r-- | ACE/ChangeLog | 36 | ||||
-rw-r--r-- | ACE/ace/Service_Config.cpp | 233 | ||||
-rw-r--r-- | ACE/ace/Service_Config.h | 111 | ||||
-rw-r--r-- | ACE/ace/Service_Config.inl | 30 | ||||
-rw-r--r-- | ACE/ace/Svc_Conf.y | 46 | ||||
-rw-r--r-- | ACE/ace/Svc_Conf_y.cpp | 56 | ||||
-rw-r--r-- | ACE/tests/Bug_2980_Regression_Test.cpp | 8 |
7 files changed, 261 insertions, 259 deletions
diff --git a/ACE/ChangeLog b/ACE/ChangeLog index cf4654f6419..9f7cb6fb5c0 100644 --- a/ACE/ChangeLog +++ b/ACE/ChangeLog @@ -1,3 +1,39 @@ +Mon Apr 7 15:21:38 UTC 2008 Iliyan Jeliazkov <iliyan@ociweb.com> + + This the second part of the SC refatoring. It builds on top of + the intrusive refcounting mechanism introduced earlier to improve + design and eliminate memory issues (leaks, SEGV on shutdown) + + * ace/Service_Config.cpp (open_i,ACE_Service_Config): + + Moved the implicit configuration file handling from open_i to + the SG instance. Eliminated close_svcs() by incorporating its + functionality in close(). + + * ace/Service_Config.inl: + * ace/Service_Config.h (ACE_Service_Config_Guard,ACE_Service_Config): + + Removing the inheritance relationship between Service Config and + Service Gestalt. To simplify the memory management, SC becomes an + interface to the actual configuration data managed by SG. Coupled + with the reference counting of SG instances, this ensures correct + memory management in multi-threaded environments where both the + TSS and the user code may trigger SG finalization. + + Introducing ACE_Threading_Helper to simplify TSS management + (RAII idiom). Changed ACE_Service_Config_Guard to use the new + smart pointer for SG. Doxygen comments cleanup. + + * ace/Svc_Conf.y: + * ace/Svc_Conf_y.cpp: + + Fixing unused function definition + + * tests/Bug_2980_Regression_Test.cpp: + + Updating the test to prevent it from breaking vxWorks builds + which appear to lack a declaration for dlopen() + Sun Apr 6 01:53:13 UTC 2008 Iliyan Jeliazkov <iliyan@ociweb.com> * ace/Service_Gestalt.cpp: diff --git a/ACE/ace/Service_Config.cpp b/ACE/ace/Service_Config.cpp index 5a374360a01..cb807a80e8c 100644 --- a/ACE/ace/Service_Config.cpp +++ b/ACE/ace/Service_Config.cpp @@ -15,9 +15,7 @@ # include "ace/Sig_Adapter.h" #endif /* !ACE_LACKS_UNIX_SIGNALS */ -#include "ace/OS_NS_stdio.h" #include "ace/OS_NS_time.h" -#include "ace/OS_NS_unistd.h" #include "ace/Get_Opt.h" #include "ace/ARGV.h" #include "ace/Log_Msg.h" @@ -41,27 +39,29 @@ typedef ACE_Unmanaged_Singleton<ACE_Service_Config, ACE_SYNCH_RECURSIVE_MUTEX> ACE_SERVICE_CONFIG_SINGLETON; -/// +/// ctor ACE_Service_Config_Guard::ACE_Service_Config_Guard (ACE_Service_Gestalt * psg) - : saved_ (ACE_Service_Config::instance ()) + : saved_ (ACE_Service_Config::current ()) { if (ACE::debug ()) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE (%P|%t) SCG:<ctor=%@>") ACE_TEXT (" - config=%@ repo=%@ superceded by repo=%@\n"), this, - this->saved_, + this->saved_.get (), this->saved_->repo_, psg->repo_)); // Modify the TSS if the repo has changed - if (saved_ != psg) - (void)ACE_Service_Config::current (psg); + ACE_Service_Config::current (psg); } ACE_Service_Config_Guard::~ACE_Service_Config_Guard (void) { - ACE_Service_Config::current (this->saved_); + ACE_Service_Gestalt* s = this->saved_.get (); + ACE_ASSERT (s != 0); + + ACE_Service_Config::current (s); if (ACE::debug ()) ACE_DEBUG ((LM_DEBUG, @@ -181,15 +181,15 @@ ACE_Service_Config::open_i (const ACE_TCHAR program_name[], ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE (%P|%t) SC::open_i - this=%@, opened=%d, ") ACE_TEXT ("loadstatics=%d\n"), - this, this->is_opened_, this->no_static_svcs_)); + this, instance_->is_opened_, instance_->no_static_svcs_)); // Guard against reentrant processing. For example, // if the singleton gestalt (ubergestalt) was already open, // do not open it again... // The base class open_i increments this and we are // forwarding to it, so we don't have to increment here. - if (this->is_opened_ != 0) - return ACE_Service_Gestalt::open_i (program_name, + if (instance_->is_opened_ != 0) + return instance_->open_i (program_name, logger_key, ignore_static_svcs, ignore_default_svc_conf_file, @@ -199,7 +199,7 @@ ACE_Service_Config::open_i (const ACE_TCHAR program_name[], // may not be safe, or wise to do an a per instance basis // Override any defaults, if required - this->no_static_svcs_ = ignore_static_svcs; + instance_->no_static_svcs_ = ignore_static_svcs; // Become a daemon before doing anything else. if (this->be_a_daemon_) @@ -232,7 +232,7 @@ ACE_Service_Config::open_i (const ACE_TCHAR program_name[], // Only use the static <logger_key_> if the caller doesn't // override it in the parameter list or if the key supplied is // equal to the default static logger key. - key = this->logger_key_; + key = instance_->logger_key_; else ACE_SET_BITS (flags, ACE_Log_Msg::LOGGER); @@ -248,7 +248,7 @@ ACE_Service_Config::open_i (const ACE_TCHAR program_name[], // Initialize the Service Repository (this will still work if // user forgets to define an object of type ACE_Service_Config). - ACE_Service_Repository::instance (ACE_Service_Config::MAX_SERVICES); + ACE_Service_Repository::instance (ACE_Service_Gestalt::MAX_SERVICES); // Initialize the ACE_Reactor (the ACE_Reactor should be the // same size as the ACE_Service_Repository). @@ -275,62 +275,17 @@ ACE_Service_Config::open_i (const ACE_TCHAR program_name[], if (result == -1) return -1; - if (this->init_svc_conf_file_queue () == -1) - return -1; - - // Check if the default file exists before attempting to queue it - // for processing - if (!ignore_default_svc_conf_file) - { - FILE *fp = ACE_OS::fopen (ACE_DEFAULT_SVC_CONF, - ACE_TEXT ("r")); - ignore_default_svc_conf_file = (fp == 0); - if (fp != 0) - ACE_OS::fclose (fp); - } - - if (!ignore_default_svc_conf_file - && this->svc_conf_file_queue_->is_empty ()) - { - // Load the default "svc.conf" entry here if there weren't - // overriding -f arguments in <parse_args>. - if (this->svc_conf_file_queue_->enqueue_tail - (ACE_TString (ACE_DEFAULT_SVC_CONF)) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("enqueuing ") - ACE_DEFAULT_SVC_CONF - ACE_TEXT(" file")), - -1); - } - } - - return ACE_Service_Gestalt::open_i (program_name, + return instance_->open_i (program_name, logger_key, ignore_static_svcs, ignore_default_svc_conf_file, ignore_debug_flag); } -// This method has changed to return the gestalt instead of the -// container, underlying the service repository and defined -// ACE_Service_Gestalt::insert (ACE_Static_Svc_Descriptor*). This way -// the existing source code can keep using -// ACE_Service_Config::static_svcs(), however now it is not necessary -// to expose the repository storage *and* it is much easier to debug -// service registration problems. - -ACE_Service_Gestalt * -ACE_Service_Config::static_svcs (void) -{ - return ACE_Service_Config::instance (); -} - /// Return the global configuration instance. Always returns the same /// instance ACE_Service_Config * -ACE_Service_Config::global (void) +ACE_Service_Config::singleton (void) { return ACE_SERVICE_CONFIG_SINGLETON::instance (); } @@ -378,17 +333,118 @@ ACE_Service_Config::resume (const ACE_TCHAR svc_name[]) ACE_Service_Config::ACE_Service_Config (bool ignore_static_svcs, size_t size, int signum) - : ACE_Service_Gestalt (size, false, ignore_static_svcs) { ACE_TRACE ("ACE_Service_Config::ACE_Service_Config"); + + // TODO: Need to find a more customizable way of instantiating the + // gestalt but perhaps we should leave this out untill such + // customizations are identified. + ACE_Service_Gestalt* tmp = 0; + ACE_NEW_NORETURN (tmp, + ACE_Service_Gestalt (size, false, ignore_static_svcs)); + + this->instance_ = tmp; + this->threadkey_.set (tmp); + + ACE_Service_Config::signum_ = signum; +} + +ACE_Service_Config::ACE_Service_Config (const ACE_TCHAR program_name[], + const ACE_TCHAR *logger_key) +{ + ACE_TRACE ("ACE_Service_Config::ACE_Service_Config"); + + // TODO: Need to find a more customizable way of instantiating the + // gestalt but perhaps we should leave this out untill such + // customizations are identified. + ACE_Service_Gestalt* tmp = 0; + ACE_NEW_NORETURN (tmp, + ACE_Service_Gestalt (ACE_Service_Repository::DEFAULT_SIZE, false)); + + this->instance_ = tmp; + this->threadkey_.set (tmp); + + if (this->open (program_name, + logger_key) == -1 && errno != ENOENT) + { + // Only print out an error if it wasn't the svc.conf file that was + // missing. + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("(%P|%t) SC failed to open: %p\n"), + program_name)); + } +} + +ACE_Threading_Helper::ACE_Threading_Helper () + : key_ (ACE_OS::NULL_key) +{ #if defined (ACE_HAS_TSS_EMULATION) ACE_Object_Manager::init_tss (); #endif - this->tss_.ts_object (this); - ACE_Service_Config::signum_ = signum; + + if (ACE_Thread::keycreate (&key_, 0, 0) == -1) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("(%P|%t) Failed to create thread key: %p\n"), + "")); + } } +ACE_Threading_Helper::~ACE_Threading_Helper () +{ +#if defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION)) + ACE_OS::thr_key_detach (this->key_, 0); + ACE_OS::thr_keyfree (this->key_); +#else // defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION)) + +#endif // defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION)) +} + +void +ACE_Threading_Helper::set (void* p) +{ + if (ACE_Thread::setspecific (key_, p) == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("(%P|%t) Service Config failed to set thread key value: %p\n"), + "")); +} + +void* +ACE_Threading_Helper::get (void) +{ + void* temp = 0; + if (ACE_Thread::getspecific (key_, &temp) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("(%P|%t) Service Config failed to get thread key value: %p\n"), + ""), + 0); + return temp; +} + + +/// Return the "global" configuration instance, for the current +/// thread. This may be the same as instance(), but on some occasions, +/// it may be a different one. For example, ACE_Service_Config_Guard +/// provides a way of temporarily replacing the "current" +/// configuration instance in the context of a thread. +ACE_Service_Gestalt* +ACE_Service_Config::current (void) +{ + void* temp = ACE_Service_Config::singleton()->threadkey_.get (); + ACE_ASSERT (temp != 0); + return static_cast<ACE_Service_Gestalt*> (temp); +} + +/// A mutator to set the "current" (TSS) gestalt instance. +void +ACE_Service_Config::current (ACE_Service_Gestalt* newcurrent) +{ + ACE_Service_Config::singleton()->threadkey_.set (newcurrent); +} + + + #if (ACE_USES_CLASSIC_SVC_CONF == 0) ACE_Service_Type * ACE_Service_Config::create_service_type (const ACE_TCHAR *n, @@ -446,29 +502,7 @@ ACE_Service_Config::create_service_type_impl (const ACE_TCHAR *name, } -ACE_Service_Config::ACE_Service_Config (const ACE_TCHAR program_name[], - const ACE_TCHAR *logger_key) - : ACE_Service_Gestalt (ACE_Service_Repository::DEFAULT_SIZE, false) -{ - ACE_TRACE ("ACE_Service_Config::ACE_Service_Config"); -#if defined (ACE_HAS_TSS_EMULATION) - ACE_Object_Manager::init_tss (); -#endif - this->tss_.ts_object (this); - if (this->open (program_name, - logger_key) == -1 && errno != ENOENT) - { - - // Only print out an error if it wasn't the svc.conf file that was - // missing. - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("(%P|%t) SC failed to open: %p\n"), - program_name)); - } -} - // Signal handling API to trigger dynamic reconfiguration. - void ACE_Service_Config::handle_signal (int sig, siginfo_t *, @@ -483,8 +517,7 @@ ACE_Service_Config::handle_signal (int sig, ACE_Service_Config::reconfig_occurred_ = 1; } -// Trigger the reconfiguration process. - +// Trigger reconfiguration to re-read configuration files. void ACE_Service_Config::reconfigure (void) { @@ -512,28 +545,19 @@ ACE_Service_Config::reconfigure (void) int ACE_Service_Config::close (void) { - int const result1 = ACE_Service_Config::instance ()->close (); + ACE_Service_Config::singleton ()->instance_->close (); // Delete the service repository. All the objects inside the // service repository should already have been finalized. - int const result2 = ACE_Service_Config::close_svcs (); + ACE_Service_Repository::close_singleton (); - // Do away with the Singleton + // Do away with the singleton ACE_Service_Config (calls dtor) ACE_SERVICE_CONFIG_SINGLETON::close (); - return (result1 | result2); -} - -int -ACE_Service_Config::close_svcs (void) -{ - ACE_TRACE ("ACE_Service_Config::close_svcs"); - - ACE_Service_Repository::close_singleton (); - ACE_Service_Config::current (global ()); return 0; } + int ACE_Service_Config::fini_svcs (void) { @@ -553,15 +577,10 @@ ACE_Service_Config::fini_svcs (void) return result; } -// Perform user-specified close activities and remove dynamic memory. - +/// Perform user-specified close activities and remove dynamic memory. ACE_Service_Config::~ACE_Service_Config (void) { ACE_TRACE ("ACE_Service_Config::~ACE_Service_Config"); - - // We do not want ~ACE_TSS<> to delete this again (single-thread - // builds) - this->tss_.ts_object (0); } // ************************************************************ diff --git a/ACE/ace/Service_Config.h b/ACE/ace/Service_Config.h index 1c1c147af8f..b9c2c77e9dc 100644 --- a/ACE/ace/Service_Config.h +++ b/ACE/ace/Service_Config.h @@ -17,8 +17,8 @@ #include /**/ "ace/config-all.h" #include "ace/Default_Constants.h" +#include "ace/Intrusive_Auto_Ptr.h" #include "ace/Service_Gestalt.h" -#include "ace/TSS_T.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once @@ -133,8 +133,38 @@ public: bool operator!= (ACE_Static_Svc_Descriptor &) const; }; +/** + * @class ACE_Threading_Helper + * + * @brief Encapsulates responsibility for allocating, destroying and + * manipulating the value, associated with a thread-specific + * key. Relates to the ability of the created thread to inherit the + * parent thread's gestalt. Designed to be used as an instance member + * of @c ACE_Service_Config + */ +class ACE_Threading_Helper +{ +public: + ACE_Threading_Helper (); + ~ACE_Threading_Helper (); + + void set (void*); + void* get (void); + +private: + + /** + * Key for the thread-specific data Service Configuration keeps + * around. This datum is a simple pointer to the configuration + * context (Gestalt). + */ + ACE_thread_key_t key_; +}; + #define ACE_Component_Config ACE_Service_Config +typedef ACE_Intrusive_Auto_Ptr<ACE_Service_Gestalt> ACE_Service_Gestalt_Auto_Ptr; + /** * @class ACE_Service_Config * @@ -166,9 +196,14 @@ public: * not eliminated, by _not_ #defining * ACE_HAS_NONSTATIC_OBJECT_MANAGER. */ -class ACE_Export ACE_Service_Config: public ACE_Service_Gestalt +class ACE_Export ACE_Service_Config { + // The Instance, or the global (default) configuration context. + // The monostate would forward the calls to that instance. The TSS + // will point here + ACE_Service_Gestalt_Auto_Ptr instance_; + public: // = Initialization and termination methods. @@ -179,7 +214,7 @@ public: * registered when the repository is opened. */ ACE_Service_Config (bool ignore_static_svcs = true, - size_t size = ACE_Service_Gestalt::MAX_SERVICES, + size_t size = ACE_DEFAULT_SERVICE_REPOSITORY_SIZE, int signum = SIGHUP); /** @@ -222,38 +257,31 @@ protected: virtual int parse_args_i (int argc, ACE_TCHAR *argv[]); /** - * A Wrapper for the TSS-stored pointer to the "current" - * configuration Gestalt. Static initializers from any DLL loaded - * through the SC will find the SC instance through the TSS pointer, - * instead of the global singleton. This makes it possible to ensure - * that the new services are loaded in the correct Gestalt, - * independent of which thread is actually using the SC at the time - * to do so. + * A helper instance to manage thread-specific key creation */ - ACE_TSS <ACE_Service_Gestalt> tss_; + ACE_Threading_Helper threadkey_; /// = Static interfaces public: /** - * Mutator to set the (TSS) global instance. Intended for use by - * helper classes like @see ACE_Service_Config_Guard. Stack-based - * instances of it can temporarily change which Gestalt is - * considered global by any static initializer (especially those in - * DLLs, loaded at run-time). + * Returns the process-wide global singleton instance. It would + * have been created and will be managed by the Object Manager. */ - static ACE_Service_Gestalt* current (ACE_Service_Gestalt*); + static ACE_Service_Config* singleton (void); /** - * Returns a process-wide global singleton instance in contrast with - * current (), which may return a different instance at different - * times, dependent on the context. Use of this method is - * discouraged as it allows circumvention of the mechanism for - * dynamically loading services. Use with extreme caution! + * Mutator for the currently active configuration context instance + * (gestalt). Intended for use by helper classes like @see + * ACE_Service_Config_Guard. Stack-based instances can be used to + * temporarily change which gestalt is seen as global by static + * initializers (especially those in DLLs loaded at run-time). */ - static ACE_Service_Config* global (void); + static void current (ACE_Service_Gestalt*); - /// Accessor for the "current" service gestalt + /** + * Accessor for the "current" service gestalt + */ static ACE_Service_Gestalt* current (void); /** @@ -264,10 +292,22 @@ public: * through static initializers. Especially important for DLL-based * dynamic services, which can contain their own static services and * static initializers. + * + * @deprecated Use current() instead. */ static ACE_Service_Gestalt* instance (void); /** + * Returns a process-wide global singleton instance in contrast with + * current (), which may return a different instance at different + * times, dependent on the context. Modifying this method's return + * value is strongly discouraged as it will circumvent the mechanism + * for dynamically loading services. If you must, use with extreme + * caution! + */ + static ACE_Service_Gestalt* global (void); + + /** * Performs an open without parsing command-line arguments. The * @a logger_key indicates where to write the logging output, which * is typically either a STREAM pipe or a socket address. If @@ -352,13 +392,6 @@ public: /// configured services in the <Service_Repository>. static int fini_svcs (void); - /** - * Perform user-specified close hooks on all of the configured - * services in the Service_Repository, then delete the - * Service_Repository itself. Returns 0. - */ - static int close_svcs (void); - /// True if reconfiguration occurred. static int reconfig_occurred (void); @@ -453,9 +486,9 @@ public: /// a string. Returns the number of errors that occurred. static int process_directive (const ACE_TCHAR directive[]); - /// Process one static service definition. /** - * Load a new static service into the ACE_Service_Repository. + * Process one static service definition. Load a new static service + * into the ACE_Service_Repository. * * @param ssd Service descriptor, see the document of * ACE_Static_Svc_Descriptor for more details. @@ -496,6 +529,7 @@ public: * for a list of files and here a list of services. */ static int parse_args (int, ACE_TCHAR *argv[]); + #if (ACE_USES_CLASSIC_SVC_CONF == 0) static ACE_Service_Type *create_service_type (const ACE_TCHAR *n, ACE_Service_Type_Impl *o, @@ -512,11 +546,13 @@ public: protected: + /// @deprecated /// Process service configuration requests that were provided on the /// command-line. Returns the number of errors that occurred. static int process_commandline_directives (void); #if (ACE_USES_CLASSIC_SVC_CONF == 1) + /// @deprecated /// This is the implementation function that process_directives() /// and process_directive() both call. Returns the number of errors /// that occurred. @@ -526,8 +562,9 @@ protected: /// Become a daemon. static int start_daemon (void); - /// Add the default statically-linked services to the - /// ACE_Service_Repository. + // @deprecated + // Add the default statically-linked services to the + // ACE_Service_Repository. static int load_static_svcs (void); @@ -585,7 +622,7 @@ private: class ACE_Export ACE_Service_Config_Guard { public: - ACE_Service_Config_Guard (ACE_Service_Gestalt * psg); + ACE_Service_Config_Guard (ACE_Service_Gestalt* psg); ~ACE_Service_Config_Guard (void); private: @@ -594,7 +631,7 @@ private: ACE_Service_Config_Guard& operator= (const ACE_Service_Config_Guard&); private: - ACE_Service_Gestalt* saved_; + ACE_Service_Gestalt_Auto_Ptr saved_; }; diff --git a/ACE/ace/Service_Config.inl b/ACE/ace/Service_Config.inl index cc57a2d4c71..79d285f2037 100644 --- a/ACE/ace/Service_Config.inl +++ b/ACE/ace/Service_Config.inl @@ -44,22 +44,18 @@ ACE_Service_Config::open (int argc, // Handle the command-line options intended for the // ACE_Service_Config. - ACE_INLINE int ACE_Service_Config::parse_args (int argc, ACE_TCHAR *argv[]) { return ACE_Service_Config::current ()->parse_args (argc, argv); } -/// Return the configuration instance, considered "global" in the -/// current thread. This may be the same as instance(), but on some -/// occasions, it may be a different one. For example, -/// ACE_Service_Config_Guard provides a way of temporarily replacing -/// the "current" configuration instance in the context of a thread. +/// Return the global configuration instance. Allways returns the same +/// instance ACE_INLINE ACE_Service_Gestalt * -ACE_Service_Config::instance (void) +ACE_Service_Config::global (void) { - return ACE_Service_Config::global ()->tss_; + return ACE_Service_Config::singleton()->instance_.get (); } /// Return the configuration instance, considered "global" in the @@ -68,19 +64,25 @@ ACE_Service_Config::instance (void) /// ACE_Service_Config_Guard provides a way of temporarily replacing /// the "current" configuration instance in the context of a thread. ACE_INLINE ACE_Service_Gestalt * -ACE_Service_Config::current (void) +ACE_Service_Config::instance (void) { - return ACE_Service_Config::global ()->tss_; + return ACE_Service_Config::current (); } -/// A mutator to set the "current" (TSS) gestalt instance. +// This method has changed to return the gestalt instead of the +// container, underlying the service repository and defined +// ACE_Service_Gestalt::insert (ACE_Static_Svc_Descriptor*). This way +// the existing source code can keep using +// ACE_Service_Config::static_svcs(), however now it is not necessary +// to expose the repository storage *and* it is much easier to debug +// service registration problems. + ACE_INLINE ACE_Service_Gestalt* -ACE_Service_Config::current (ACE_Service_Gestalt *newcurrent) +ACE_Service_Config::static_svcs (void) { - return ACE_Service_Config::global ()->tss_.ts_object (newcurrent); + return ACE_Service_Config::current (); } - /// Compare two service descriptors for equality. ACE_INLINE bool ACE_Static_Svc_Descriptor::operator== (ACE_Static_Svc_Descriptor &d) const diff --git a/ACE/ace/Svc_Conf.y b/ACE/ace/Svc_Conf.y index e5ceea16b6a..983e997d589 100644 --- a/ACE/ace/Svc_Conf.y +++ b/ACE/ace/Svc_Conf.y @@ -23,10 +23,6 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL // Prototypes. static ACE_Module_Type *ace_get_module (ACE_Service_Type const * sr, - ACE_Service_Type const * sv, - int & ace_yyerrno); - -static ACE_Module_Type *ace_get_module (ACE_Service_Type const * sr, ACE_TCHAR const * svc_name, int & ace_yyerrno); @@ -344,48 +340,6 @@ ace_get_module (ACE_Service_Type const * sr, return const_cast<ACE_Module_Type *> (mt); } -static ACE_Module_Type * -ace_get_module (ACE_Service_Type const * sr, - ACE_Service_Type const * sv, - int & yyerrno) -{ - ACE_Stream_Type const * const st = - (sr == 0 - ? 0 - : static_cast<ACE_Stream_Type const *> (sr->type ())); - - ACE_Module_Type const * const mt = - static_cast <ACE_Module_Type const *> (sv->type ()); - - ACE_TCHAR const * const module_type_name = - (mt ? mt->name () : ACE_TEXT ("(nil)")); - - if (sr == 0 || st == 0 || mt == 0) - { - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("cannot locate Module_Type %s or STREAM_Type %s\n"), - module_type_name, - (sr ? sr->name () : ACE_TEXT ("(nil)")))); - ++yyerrno; - } - - // Make sure that the Module has the same name as the - // Module_Type object from the svc.conf file. - ACE_Module<ACE_SYNCH> * const mp = - static_cast<ACE_Module<ACE_SYNCH> *> (mt ? mt->object () : 0); - - if (mp && ACE_OS::strcmp (mp->name (), module_type_name) != 0) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("warning: assigning Module_Type name %s to Module %s since names differ\n"), - module_type_name, - mp->name ())); - mp->name (module_type_name); - } - - return const_cast<ACE_Module_Type *> (mt); -} - #if defined (SVC_CONF_Y_DEBUGGING) // Main driver program. diff --git a/ACE/ace/Svc_Conf_y.cpp b/ACE/ace/Svc_Conf_y.cpp index 773902e927b..678b85fb672 100644 --- a/ACE/ace/Svc_Conf_y.cpp +++ b/ACE/ace/Svc_Conf_y.cpp @@ -128,10 +128,6 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL // Prototypes. static ACE_Module_Type *ace_get_module (ACE_Service_Type const * sr, - ACE_Service_Type const * sv, - int & ace_ace_yyerrno); - -static ACE_Module_Type *ace_get_module (ACE_Service_Type const * sr, ACE_TCHAR const * svc_name, int & ace_ace_yyerrno); @@ -473,11 +469,11 @@ static const ace_yytype_int8 ace_yyrhs[] = /* ACE_YYRLINE[ACE_YYN] -- source line where rule number ACE_YYN was defined. */ static const ace_yytype_uint16 ace_yyrline[] = { - 0, 62, 62, 71, 75, 79, 80, 81, 82, 83, - 84, 88, 98, 105, 112, 119, 126, 130, 130, 137, - 140, 147, 146, 155, 159, 167, 171, 174, 188, 197, - 206, 228, 235, 239, 244, 250, 254, 258, 265, 269, - 273, 280, 281, 285, 286, 287 + 0, 58, 58, 67, 71, 75, 76, 77, 78, 79, + 80, 84, 94, 101, 108, 115, 122, 126, 126, 133, + 136, 143, 142, 151, 155, 163, 167, 170, 184, 193, + 202, 224, 231, 235, 240, 246, 250, 254, 261, 265, + 269, 276, 277, 281, 282, 283 }; #endif @@ -1966,48 +1962,6 @@ ace_get_module (ACE_Service_Type const * sr, return const_cast<ACE_Module_Type *> (mt); } -static ACE_Module_Type * -ace_get_module (ACE_Service_Type const * sr, - ACE_Service_Type const * sv, - int & ace_yyerrno) -{ - ACE_Stream_Type const * const st = - (sr == 0 - ? 0 - : static_cast<ACE_Stream_Type const *> (sr->type ())); - - ACE_Module_Type const * const mt = - static_cast <ACE_Module_Type const *> (sv->type ()); - - ACE_TCHAR const * const module_type_name = - (mt ? mt->name () : ACE_TEXT ("(nil)")); - - if (sr == 0 || st == 0 || mt == 0) - { - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("cannot locate Module_Type %s or STREAM_Type %s\n"), - module_type_name, - (sr ? sr->name () : ACE_TEXT ("(nil)")))); - ++ace_yyerrno; - } - - // Make sure that the Module has the same name as the - // Module_Type object from the svc.conf file. - ACE_Module<ACE_SYNCH> * const mp = - static_cast<ACE_Module<ACE_SYNCH> *> (mt ? mt->object () : 0); - - if (mp && ACE_OS::strcmp (mp->name (), module_type_name) != 0) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("warning: assigning Module_Type name %s to Module %s since names differ\n"), - module_type_name, - mp->name ())); - mp->name (module_type_name); - } - - return const_cast<ACE_Module_Type *> (mt); -} - #if defined (SVC_CONF_Y_DEBUGGING) // Main driver program. diff --git a/ACE/tests/Bug_2980_Regression_Test.cpp b/ACE/tests/Bug_2980_Regression_Test.cpp index 90beef77103..0cc4f5934a8 100644 --- a/ACE/tests/Bug_2980_Regression_Test.cpp +++ b/ACE/tests/Bug_2980_Regression_Test.cpp @@ -8,7 +8,7 @@ // platform-specific ones. Luckily, it is only Windows where this // test has not been made to work yet ... -#if !defined (WIN32) +#if !(defined (WIN32) || defined (VXWORKS)) #include <dlfcn.h> #include <pthread.h> @@ -85,12 +85,12 @@ void * loadunloadDll(void *pp) return 0; } -#endif /* !defined (ACE_WIN32) */ +#endif /* !(defined (WIN32) || defined (VXWORKS)) */ int main(int, char **) { -#if defined (WIN32) +#if (defined (WIN32) || defined (VXWORKS)) printf ("Terminating because this test has not been designed " "to run on platforms where WIN32 has been defined.\n"); @@ -132,7 +132,7 @@ int main(int, char **) printf ("main - leaving\n"); -#endif /* defined (ACE_WIN32) */ +#endif /* (defined (WIN32) || defined (VXWORKS)) */ return 0; } |