diff options
author | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-11-01 13:56:11 +0000 |
---|---|---|
committer | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-11-01 13:56:11 +0000 |
commit | da63b6a384139a16c1c0750b0448daf0ed923f28 (patch) | |
tree | cada797c9a0a4c049f095bb2e143cd06f494057e /ace | |
parent | 498fdb40a8cfe58a1a6470d7f63c10e815ad9c88 (diff) | |
download | ATCD-da63b6a384139a16c1c0750b0448daf0ed923f28.tar.gz |
moved static ACE_Service_Config::signal_handler_ to Object_Manager
Diffstat (limited to 'ace')
-rw-r--r-- | ace/Object_Manager.cpp | 12 | ||||
-rw-r--r-- | ace/Service_Config.cpp | 93 | ||||
-rw-r--r-- | ace/Service_Config.h | 50 | ||||
-rw-r--r-- | ace/Service_Config.i | 6 |
4 files changed, 91 insertions, 70 deletions
diff --git a/ace/Object_Manager.cpp b/ace/Object_Manager.cpp index b20e7e6619a..9567e59d5d2 100644 --- a/ace/Object_Manager.cpp +++ b/ace/Object_Manager.cpp @@ -6,6 +6,7 @@ #include "ace/Containers.h" #include "ace/Array.h" #include "ace/Service_Config.h" +#include "ace/Signal.h" #include "ace/Log_Msg.h" #include "ace/Token_Manager.h" #include "ace/Synch.h" @@ -31,6 +32,7 @@ # define ACE_APPLICATION_PREALLOCATED_ARRAY_DELETIONS #endif /* ACE_APPLICATION_PREALLOCATED_ARRAY_DELETIONS */ + // Static data. ACE_Object_Manager *ACE_Object_Manager::instance_ = 0; @@ -47,6 +49,8 @@ void *ACE_Object_Manager::preallocated_object[ void *ACE_Object_Manager::preallocated_array[ ACE_Object_Manager::ACE_PREALLOCATED_ARRAYS] = { 0 }; +ACE_Sig_Adapter *ace_service_config_sig_handler = 0; + // Handy macros for use by ACE_Object_Manager constructor to preallocate or // delete an object or array, either statically (in global data) or // dynamically (on the heap). @@ -126,6 +130,11 @@ ACE_Object_Manager::ACE_Object_Manager (void) ACE_APPLICATION_PREALLOCATED_OBJECT_DEFINITIONS ACE_APPLICATION_PREALLOCATED_ARRAY_DEFINITIONS + // Construct the ACE_Service_Config's signal handler. + ACE_NEW (ace_service_config_sig_handler, + ACE_Sig_Adapter (&ACE_Service_Config::handle_signal)); + ACE_Service_Config::signal_handler (ace_service_config_sig_handler); + #if defined (ACE_HAS_TSS_EMULATION) // Initialize the main thread's TS storage. ACE_TSS_Emulation::tss_open (ts_storage_); @@ -501,6 +510,9 @@ ACE_Object_Manager::~ACE_Object_Manager (void) // Close down Winsock (no-op on other platforms). ACE_OS::socket_fini (); + delete ace_service_config_sig_handler; + ace_service_config_sig_handler = 0; + ACE_MT (delete lock_; lock_ = 0); diff --git a/ace/Service_Config.cpp b/ace/Service_Config.cpp index 36bac60aabe..f7e7d6a201b 100644 --- a/ace/Service_Config.cpp +++ b/ace/Service_Config.cpp @@ -39,7 +39,7 @@ ACE_SVC_FACTORY_DEFINE (ACE_Service_Manager) // ---------------------------------------- // Set the signal handler to point to the handle_signal() function. -ACE_Sig_Adapter ACE_Service_Config::signal_handler_ (&ACE_Service_Config::handle_signal); +ACE_Sig_Adapter *ACE_Service_Config::signal_handler_ = 0; // Trigger a reconfiguration. sig_atomic_t ACE_Service_Config::reconfig_occurred_ = 0; @@ -60,8 +60,8 @@ LPCTSTR ACE_Service_Config::logger_key_ = ACE_LOGGER_KEY; // Define the object that describes the service statically. ACE_STATIC_SVC_DEFINE (ACE_Service_Manager, - "ACE_Service_Manager", ACE_SVC_OBJ_T, &ACE_SVC_NAME (ACE_Service_Manager), - ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ, 0) + "ACE_Service_Manager", ACE_SVC_OBJ_T, &ACE_SVC_NAME (ACE_Service_Manager), + ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ, 0) // Add this to the list of statically configured services. ACE_STATIC_SVC_REQUIRE (ACE_Service_Manager) @@ -174,8 +174,8 @@ ACE_Service_Config::resume (const char svc_name[]) // to allow static configuration of services... ACE_Service_Config::ACE_Service_Config (int ignore_static_svcs, - size_t size, - int signum) + size_t size, + int signum) { ACE_TRACE ("ACE_Service_Config::ACE_Service_Config"); ACE_Service_Config::no_static_svcs_ = (char) ignore_static_svcs; @@ -194,7 +194,7 @@ ACE_Service_Config::ACE_Service_Config (int ignore_static_svcs, // This really ought to be a Singleton I suspect... if (ACE_Reactor::instance ()->register_handler (ACE_Service_Config::signum_, - &ACE_Service_Config::signal_handler_) == -1) + ACE_Service_Config::signal_handler_) == -1) ACE_ERROR ((LM_ERROR, "can't register signal handler\n")); #endif /* ACE_LACKS_UNIX_SIGNALS */ } @@ -212,34 +212,34 @@ ACE_Service_Config::parse_args (int argc, char *argv[]) switch (c) { case 'b': - ACE_Service_Config::be_a_daemon_ = 1; - break; + ACE_Service_Config::be_a_daemon_ = 1; + break; case 'd': - ACE_Service_Config::debug_ = 1; - break; + ACE_Service_Config::debug_ = 1; + break; case 'f': - ACE_Service_Config::service_config_file_ = getopt.optarg; - break; + ACE_Service_Config::service_config_file_ = getopt.optarg; + break; case 'n': - ACE_Service_Config::no_static_svcs_ = 1; - break; + ACE_Service_Config::no_static_svcs_ = 1; + break; case 's': - { + { // There's no point in dealing with this on NT since it doesn't really // support signals very well... #if !defined (ACE_LACKS_UNIX_SIGNALS) - ACE_Service_Config::signum_ = ACE_OS::atoi (getopt.optarg); + ACE_Service_Config::signum_ = ACE_OS::atoi (getopt.optarg); - if (ACE_Reactor::instance ()->register_handler - (ACE_Service_Config::signum_, - &ACE_Service_Config::signal_handler_) == -1) - ACE_ERROR ((LM_ERROR, "cannot obtain signal handler\n")); + if (ACE_Reactor::instance ()->register_handler + (ACE_Service_Config::signum_, + ACE_Service_Config::signal_handler_) == -1) + ACE_ERROR ((LM_ERROR, "cannot obtain signal handler\n")); #endif /* ACE_LACKS_UNIX_SIGNALS */ - break; - } + break; + } default: - ACE_ERROR ((LM_ERROR, "%c is not a ACE_Service_Config option\n", c)); - break; + ACE_ERROR ((LM_ERROR, "%c is not a ACE_Service_Config option\n", c)); + break; } } @@ -247,7 +247,7 @@ ACE_Service_Config::parse_args (int argc, char *argv[]) int ACE_Service_Config::initialize (const char svc_name[], - char *parameters) + char *parameters) { ACE_TRACE ("ACE_Service_Config::initialize"); ACE_ARGV args (parameters); @@ -256,12 +256,12 @@ ACE_Service_Config::initialize (const char svc_name[], ACE_DEBUG ((LM_DEBUG, "opening static service %s\n", svc_name)); if (ACE_Service_Repository::instance ()->find (svc_name, - (const ACE_Service_Type **) &srp) == -1) + (const ACE_Service_Type **) &srp) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%s not found\n", svc_name), -1); else if (srp->type ()->init (args.argc (), args.argv ()) == -1) ACE_ERROR_RETURN ((LM_ERROR, "static initialization failed, %p\n", - svc_name), -1); + svc_name), -1); else { srp->active (1); @@ -274,7 +274,7 @@ ACE_Service_Config::initialize (const char svc_name[], int ACE_Service_Config::initialize (const ACE_Service_Type *sr, - char parameters[]) + char parameters[]) { ACE_TRACE ("ACE_Service_Config::initialize"); ACE_ARGV args (parameters); @@ -286,7 +286,7 @@ ACE_Service_Config::initialize (const ACE_Service_Type *sr, else if (sr->type ()->init (args.argc (), args.argv ()) == -1) ACE_ERROR_RETURN ((LM_ERROR, "dynamic initialization failed for %s\n", - sr->name ()), -1); + sr->name ()), -1); else return 0; } @@ -310,7 +310,7 @@ ACE_Service_Config::process_directives (void) { // AC 970827 Skip the heap check because yacc allocates a buffer // here which will be reported as a memory leak for some reason. - ACE_NO_HEAP_CHECK + ACE_NO_HEAP_CHECK ace_yyrestart (fp); @@ -326,12 +326,12 @@ ACE_Service_Config::process_directives (void) ace_yyparse (); if (ace_yyerrno > 0) - { - errno = EINVAL; // This is a hack, better errors should be provided... - return ace_yyerrno; - } + { + errno = EINVAL; // This is a hack, better errors should be provided... + return ace_yyerrno; + } else - return 0; + return 0; } } @@ -353,20 +353,20 @@ ACE_Service_Config::load_static_svcs (void) ACE_Static_Svc_Descriptor *ssd = *ssdp; ACE_Service_Type_Impl *stp = - ace_create_service_type (ssd->name_, - ssd->type_, - (const void *) (*ssd->alloc_)(), - ssd->flags_); + ace_create_service_type (ssd->name_, + ssd->type_, + (const void *) (*ssd->alloc_)(), + ssd->flags_); if (stp == 0) - continue; + continue; ACE_Service_Type *sr; ACE_NEW_RETURN (sr, ACE_Service_Type (ssd->name_, stp, - 0, ssd->active_), -1); + 0, ssd->active_), -1); if (ACE_Service_Repository::instance ()->insert (sr) == -1) - return -1; + return -1; } return 0; } @@ -384,8 +384,8 @@ ACE_Service_Config::open (const char program_name[]) // Only use STDERR if the users hasn't already set the flags. if (ACE_LOG_MSG->open (program_name, - ACE_LOG_MSG->flags () ? ACE_LOG_MSG->flags () : (u_long) ACE_Log_Msg::STDERR, - ACE_Service_Config::logger_key_) == -1) + ACE_LOG_MSG->flags () ? ACE_LOG_MSG->flags () : (u_long) ACE_Log_Msg::STDERR, + ACE_Service_Config::logger_key_) == -1) return -1; ACE_DEBUG ((LM_STARTUP, "starting up daemon %n\n")); @@ -427,8 +427,8 @@ ACE_Service_Config::handle_signal (int sig, siginfo_t *, ucontext_t *) if (ACE_Service_Config::signum_ != sig) ACE_ERROR ((LM_ERROR, - "error, signal %S does match %S\n", - sig, ACE_Service_Config::signum_)); + "error, signal %S does match %S\n", + sig, ACE_Service_Config::signum_)); if (ACE_Service_Config::debug_) ACE_DEBUG ((LM_DEBUG, "signal %S occurred\n", sig)); @@ -591,4 +591,3 @@ template class ACE_Auto_Basic_Ptr<ACE_Obstack>; #pragma instantiate auto_ptr<ACE_Obstack> #pragma instantiate ACE_Auto_Basic_Ptr<ACE_Obstack> #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ - diff --git a/ace/Service_Config.h b/ace/Service_Config.h index 49a1083a1db..a189b35a8f3 100644 --- a/ace/Service_Config.h +++ b/ace/Service_Config.h @@ -5,13 +5,13 @@ // // = LIBRARY // ace -// +// // = FILENAME // Service_Config.h // // = AUTHOR -// Doug Schmidt -// +// Doug Schmidt +// // ============================================================================ #if !defined (ACE_SERVICE_CONFIG_H) @@ -37,13 +37,13 @@ struct ACE_Static_Svc_Descriptor { char *name_; // Name of the service. - + int type_; // Type of service. ACE_SERVICE_ALLOCATOR alloc_; // Factory function that allocates the service. - + u_int flags_; // Bitmask flags indicating how the framework should delete memory. @@ -76,9 +76,9 @@ public: // = Initialization and termination methods. - ACE_Service_Config (int ignore_static_svcs = 0, - size_t size = ACE_Service_Config::MAX_SERVICES, - int signum = SIGHUP); + ACE_Service_Config (int ignore_static_svcs = 0, + size_t size = ACE_Service_Config::MAX_SERVICES, + int signum = SIGHUP); // Initialize the Service Repository. ACE_Service_Config (const char program_name[]); @@ -109,7 +109,7 @@ public: // <Service_Repository> itself. // @@ What is its return value? - static int close_singletons (void); + static int close_singletons (void); // Delete the dynamically allocated Singletons (i.e., the <Reactor>, // <Proactor>, <ReactorEx>, <Thread_Manager>, and <Allocator>). // @@ What is its return value? @@ -177,7 +177,7 @@ public: static ACE_Service_Repository *svc_rep (ACE_Service_Repository *); // Set pointer to a process-wide <ACE_Service_Repository> and return - // existing pointer. + // existing pointer. // DO NOT USE THIS METHOD. It may be unsupported in future releases. // Use ACE_Service_Repository::instance() instead. @@ -207,30 +207,33 @@ public: // of the Service Configurator class category. static int initialize (const ACE_Service_Type *, char parameters[]); // Dynamically link the shared object file and retrieve - // a pointer to the designated shared object in this file. + // a pointer to the designated shared object in this file. static int initialize (const char svc_name[], char parameters[]); - // Initialize and activate a statically <svc_name> service. + // Initialize and activate a statically <svc_name> service. static int resume (const char svc_name[]); // Resume a <svc_name> that was previously suspended or has not yet - // been resumed (e.g., a static service). + // been resumed (e.g., a static service). static int suspend (const char svc_name[]); - // Suspend <svc_name>. Note that this will not unlink the service - // from the daemon if it was dynamically linked, it will mark it + // Suspend <svc_name>. Note that this will not unlink the service + // from the daemon if it was dynamically linked, it will mark it // as being suspended in the Service Repository and call the - // suspend() member function on the appropriate ACE_Service_Object. - // A service can be resumed later on by calling the RESUME() - // member function... + // suspend() member function on the appropriate ACE_Service_Object. + // A service can be resumed later on by calling the RESUME() + // member function... static int remove (const char svc_name[]); - // Totally remove <svc_name> from the daemon by removing it + // Totally remove <svc_name> from the daemon by removing it // from the ACE_Reactor, and unlinking it if necessary. void dump (void) const; // Dump the state of an object. + static ACE_INLINE void signal_handler (ACE_Sig_Adapter *); + // Set the signal_handler;for internal use by ACE_Object_Manager only. + ACE_ALLOC_HOOK_DECLARE; // Declare the dynamic allocation hooks. @@ -245,11 +248,12 @@ protected: // program name. static int start_daemon (void); - // Become a daemon. + // Become a daemon. static int load_static_svcs (void); // Add the default statically-linked services to the <ACE_Service_Repository>. +public: static void handle_signal (int sig, siginfo_t *, ucontext_t *); // Handles signals to trigger reconfigurations. @@ -269,7 +273,7 @@ private: static sig_atomic_t reconfig_occurred_; // True if reconfiguration occurred. - // = Set by command-line options. + // = Set by command-line options. static char debug_; static char be_a_daemon_; static char no_static_svcs_; @@ -277,7 +281,7 @@ private: static int signum_; // Number of the signal used to trigger reconfiguration. - static ACE_Sig_Adapter signal_handler_; + static ACE_Sig_Adapter *signal_handler_; // Handles the reconfiguration signals. }; @@ -286,7 +290,7 @@ private: #endif /* __ACE_INLINE__ */ // These must go here to avoid circular includes... -// (only left here for to not break applications +// (only left here for to not break applications // which rely on this - no real need any longer) #include "ace/Reactor.h" #include "ace/Svc_Conf_Tokens.h" diff --git a/ace/Service_Config.i b/ace/Service_Config.i index f14659e6d92..9d761ef92b1 100644 --- a/ace/Service_Config.i +++ b/ace/Service_Config.i @@ -21,3 +21,9 @@ ACE_Static_Svc_Descriptor::operator== (struct ACE_Static_Svc_Descriptor &d) cons { return ACE_OS::strcmp (name_, d.name_) == 0; } + +ACE_INLINE void +ACE_Service_Config::signal_handler (ACE_Sig_Adapter *signal_handler) +{ + signal_handler_ = signal_handler; +} |