Supplies common server operations for dynamic and static configuration of service. More...
#include <Service_Config.h>

Public Member Functions | |
| ACE_Service_Config (bool ignore_static_svcs=true, size_t size=ACE_DEFAULT_SERVICE_REPOSITORY_SIZE, int signum=SIGHUP) | |
| ACE_Service_Config (const ACE_TCHAR program_name[], const ACE_TCHAR *logger_key=ACE_DEFAULT_LOGGER_KEY) | |
| virtual | ~ACE_Service_Config (void) |
| void | dump (void) const |
| Dump the state of an object. | |
Static Public Member Functions | |
| static ACE_Service_Config * | singleton (void) |
| = Static interfaces | |
| static void | current (ACE_Service_Gestalt *) |
| A mutator to set the "current" (TSS) gestalt instance. | |
| static ACE_Service_Gestalt * | current (void) |
| static ACE_Service_Gestalt * | instance (void) |
| static ACE_Service_Gestalt * | global (void) |
| static int | open (const ACE_TCHAR program_name[], const ACE_TCHAR *logger_key=ACE_DEFAULT_LOGGER_KEY, bool ignore_static_svcs=true, bool ignore_default_svc_conf_file=false, bool ignore_debug_flag=false) |
| static int | open (int argc, ACE_TCHAR *argv[], const ACE_TCHAR *logger_key=ACE_DEFAULT_LOGGER_KEY, bool ignore_static_svcs=true, bool ignore_default_svc_conf_file=false, bool ignore_debug_flag=false) |
| static int | close (void) |
| static int | fini_svcs (void) |
| static int | reconfig_occurred (void) |
| True if reconfiguration occurred. | |
| static void | reconfig_occurred (int) |
| Indicate that reconfiguration occurred. | |
| static void | reconfigure (void) |
| Perform the reconfiguration process. | |
| static ACE_Service_Gestalt * | static_svcs (void) |
| static int | insert (ACE_Static_Svc_Descriptor *svc) |
| static int | initialize (const ACE_Service_Type *, const ACE_TCHAR *parameters) |
| static int | initialize (const ACE_TCHAR *svc_name, const ACE_TCHAR *parameters) |
| Initialize and activate a statically svc_name service. | |
| static int | resume (const ACE_TCHAR svc_name[]) |
| static int | suspend (const ACE_TCHAR svc_name[]) |
| static int | remove (const ACE_TCHAR svc_name[]) |
| static int | initialize (const ACE_Service_Type *, ACE_ANTI_TCHAR[]) |
| static int | initialize (const char svc_name[], ACE_ANTI_TCHAR parameters[]) |
| static int | resume (const ACE_ANTI_TCHAR svc_name[]) |
| static int | suspend (const ACE_ANTI_TCHAR svc_name[]) |
| static int | remove (const ACE_ANTI_TCHAR svc_name[]) |
| static ACE_INLINE void | signal_handler (ACE_Sig_Adapter *) |
| Set the signal_handler;for internal use by ACE_Object_Manager only. | |
| static int | process_file (const ACE_TCHAR file[]) |
| static int | process_directive (const ACE_TCHAR directive[]) |
| static int | process_directive (const ACE_Static_Svc_Descriptor &ssd, bool force_replace=false) |
| static int | process_directives (void) |
| static void | handle_signal (int sig, siginfo_t *, ucontext_t *) |
| Handles signals to trigger reconfigurations. | |
| static int | parse_args (int, ACE_TCHAR *argv[]) |
| static ACE_Service_Type * | create_service_type (const ACE_TCHAR *n, ACE_Service_Type_Impl *o, ACE_DLL &dll, int active) |
| static ACE_Service_Type_Impl * | create_service_type_impl (const ACE_TCHAR *name, int type, void *symbol, u_int flags, ACE_Service_Object_Exterminator gobbler) |
| static int | process_commandline_directives (void) |
| static int | start_daemon (void) |
| Become a daemon. | |
| static int | load_static_svcs (void) |
Public Attributes | |
| ACE_ALLOC_HOOK_DECLARE | |
| Declare the dynamic allocation hooks. | |
Static Protected Member Functions | |
| static int | process_directives_i (ACE_Svc_Conf_Param *param) |
Private Member Functions | |
| virtual int | open_i (const ACE_TCHAR program_name[], const ACE_TCHAR *logger_key, bool ignore_static_svcs, bool ignore_default_svc_conf_file, bool ignore_debug_flag) |
| virtual int | parse_args_i (int argc, ACE_TCHAR *argv[]) |
Private Attributes | |
| ACE_Intrusive_Auto_Ptr < ACE_Service_Gestalt > | instance_ |
| ACE_Threading_Helper < ACE_SYNCH_MUTEX > | threadkey_ |
| bool | is_opened_ |
| Have we called ACE_Service_Config::open() yet? | |
| ACE_SYNCH_MUTEX | lock_ |
| Synchronization variable for open, etc. | |
Static Private Attributes | |
| static sig_atomic_t | reconfig_occurred_ = 0 |
| True if reconfiguration occurred. | |
| static bool | be_a_daemon_ = false |
| Shall we become a daemon process? | |
| static ACE_TCHAR * | pid_file_name_ = 0 |
| Pathname of file to write process id. | |
| static int | signum_ = SIGHUP |
| Number of the signal used to trigger reconfiguration. | |
| static ACE_Sig_Adapter * | signal_handler_ = 0 |
| Handles the reconfiguration signals. | |
Friends | |
| class | ACE_Service_Config_Guard |
| class | ACE_Threading_Helper< ACE_Thread_Mutex > |
| The helper needs intimate access (when building with no threads). | |
| class | ACE_Threading_Helper< ACE_Null_Mutex > |
Supplies common server operations for dynamic and static configuration of service.
The ACE_Service_Config uses the Monostate pattern. Therefore, you can only have one of these instantiated per-process. It represents the process-wide collection of services, which is typicaly shared among all other configurable entities. The only ACE_Service_Config instance is registered with and owned by the ACE_Object_Manager.
By contrast, the ACE_Service_Gestalt represents the collection of services, pertaining to a configurable entity. Typicaly, a "configurable entity" is an instance, which owns an instance of ACE_Service_Gestalt in order to ensure full controll over the services it needs.
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 curent() method.
Definition at line 221 of file Service_Config.h.
| ACE_Service_Config::ACE_Service_Config | ( | bool | ignore_static_svcs = true, |
|
| size_t | size = ACE_DEFAULT_SERVICE_REPOSITORY_SIZE, |
|||
| int | signum = SIGHUP | |||
| ) |
Initialize the Service Repository. Note that initialising signum to a negative number will prevent a signal handler being registered when the repository is opened.
Definition at line 372 of file Service_Config.cpp.
00375 { 00376 ACE_TRACE ("ACE_Service_Config::ACE_Service_Config"); 00377 00378 // TODO: Need to find a more customizable way of instantiating the 00379 // gestalt but perhaps we should leave this out untill such 00380 // customizations are identified. 00381 ACE_Service_Gestalt* tmp = 0; 00382 ACE_NEW_NORETURN (tmp, 00383 ACE_Service_Gestalt (size, false, ignore_static_svcs)); 00384 00385 this->is_opened_ = false; 00386 this->instance_ = tmp; 00387 this->threadkey_.set (tmp); 00388 00389 ACE_Service_Config::signum_ = signum; 00390 }
| ACE_Service_Config::ACE_Service_Config | ( | const ACE_TCHAR | program_name[], | |
| const ACE_TCHAR * | logger_key = ACE_DEFAULT_LOGGER_KEY | |||
| ) |
Performs an open without parsing command-line arguments. The logger_key indicates where to write the logging output, which is typically either a STREAM pipe or a socket address.
Definition at line 392 of file Service_Config.cpp.
00394 { 00395 ACE_TRACE ("ACE_Service_Config::ACE_Service_Config"); 00396 00397 // TODO: Need to find a more customizable way of instantiating the 00398 // gestalt but perhaps we should leave this out untill such 00399 // customizations are identified. 00400 ACE_Service_Gestalt* tmp = 0; 00401 ACE_NEW_NORETURN (tmp, 00402 ACE_Service_Gestalt (ACE_Service_Repository::DEFAULT_SIZE, false)); 00403 00404 this->is_opened_ = false; 00405 this->instance_ = tmp; 00406 this->threadkey_.set (tmp); 00407 00408 if (this->open (program_name, 00409 logger_key) == -1 && errno != ENOENT) 00410 { 00411 // Only print out an error if it wasn't the svc.conf file that was 00412 // missing. 00413 ACE_ERROR ((LM_ERROR, 00414 ACE_TEXT ("(%P|%t) SC failed to open: %p\n"), 00415 program_name)); 00416 } 00417 }
| ACE_Service_Config::~ACE_Service_Config | ( | void | ) | [virtual] |
Perform user-specified close activities and remove dynamic memory.
Definition at line 588 of file Service_Config.cpp.
00589 { 00590 ACE_TRACE ("ACE_Service_Config::~ACE_Service_Config"); 00591 }
| int ACE_Service_Config::close | ( | void | ) | [static] |
Tidy up and perform last rites when ACE_Service_Config is shut down. This method calls close_svcs(). Returns 0.
Definition at line 553 of file Service_Config.cpp.
00554 { 00555 ACE_Service_Config::singleton ()->instance_->close (); 00556 00557 // Delete the service repository. All the objects inside the 00558 // service repository should already have been finalized. 00559 ACE_Service_Repository::close_singleton (); 00560 00561 // Do away with the singleton ACE_Service_Config (calls dtor) 00562 ACE_SERVICE_CONFIG_SINGLETON::close (); 00563 00564 return 0; 00565 }
| ACE_Service_Type * ACE_Service_Config::create_service_type | ( | const ACE_TCHAR * | n, | |
| ACE_Service_Type_Impl * | o, | |||
| ACE_DLL & | dll, | |||
| int | active | |||
| ) | [static] |
Definition at line 457 of file Service_Config.cpp.
00461 { 00462 ACE_Service_Type *sp = 0; 00463 ACE_NEW_RETURN (sp, 00464 ACE_Service_Type (n, o, dll, active), 00465 0); 00466 return sp; 00467 }
| ACE_Service_Type_Impl * ACE_Service_Config::create_service_type_impl | ( | const ACE_TCHAR * | name, | |
| int | type, | |||
| void * | symbol, | |||
| u_int | flags, | |||
| ACE_Service_Object_Exterminator | gobbler | |||
| ) | [static] |
Definition at line 471 of file Service_Config.cpp.
00476 { 00477 ACE_Service_Type_Impl *stp = 0; 00478 00479 // Note, the only place we need to put a case statement. This is 00480 // also the place where we'd put the RTTI tests, if the compiler 00481 // actually supported them! 00482 00483 switch (type) 00484 { 00485 case ACE_Service_Type::SERVICE_OBJECT: 00486 ACE_NEW_RETURN (stp, 00487 ACE_Service_Object_Type ((ACE_Service_Object *) symbol, 00488 name, flags, 00489 gobbler), 00490 0); 00491 break; 00492 case ACE_Service_Type::MODULE: 00493 ACE_NEW_RETURN (stp, 00494 ACE_Module_Type (symbol, name, flags), 00495 0); 00496 break; 00497 case ACE_Service_Type::STREAM: 00498 ACE_NEW_RETURN (stp, 00499 ACE_Stream_Type (symbol, name, flags), 00500 0); 00501 break; 00502 default: 00503 ACE_ERROR ((LM_ERROR, 00504 ACE_TEXT ("unknown case\n"))); 00505 break; 00506 } 00507 return stp; 00508 00509 }
| ACE_Service_Gestalt * ACE_Service_Config::current | ( | void | ) | [static] |
Accessor for the "current" service gestalt
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.
Definition at line 425 of file Service_Config.cpp.
00426 { 00427 void* temp = ACE_Service_Config::singleton()->threadkey_.get (); 00428 if (temp == 0) { 00429 00430 // The most likely reason is that the current thread was spawned 00431 // by some native primitive, like pthreads or Windows API - not 00432 // from ACE. This is perfectly legal for callers who are not, or 00433 // do not need to be ACE-aware. Such callers must have no 00434 // expectation that the pluggable, multi-context configuration 00435 // support will work - they would always get the global context, 00436 // because at this point there is no information what the "parent" 00437 // thread's configuration context was. 00438 00439 temp = global(); 00440 singleton()->threadkey_.set (temp); 00441 } 00442 00443 return static_cast<ACE_Service_Gestalt*> (temp); 00444 }
| void ACE_Service_Config::current | ( | ACE_Service_Gestalt * | newcurrent | ) | [static] |
A mutator to set the "current" (TSS) gestalt instance.
Mutator for the currently active configuration context instance (gestalt). Intended for use by helper classes like
Definition at line 448 of file Service_Config.cpp.
00449 { 00450 ACE_Service_Config::singleton()->threadkey_.set (newcurrent); 00451 }
| void ACE_Service_Config::dump | ( | void | ) | const |
Dump the state of an object.
Definition at line 160 of file Service_Config.cpp.
00161 { 00162 #if defined (ACE_HAS_DUMP) 00163 ACE_TRACE ("ACE_Service_Config::dump"); 00164 #endif /* ACE_HAS_DUMP */ 00165 }
| int ACE_Service_Config::fini_svcs | ( | void | ) | [static] |
Perform user-specified close hooks and possibly delete all of the configured services in the <Service_Repository>.
Definition at line 569 of file Service_Config.cpp.
00570 { 00571 ACE_TRACE ("ACE_Service_Config::fini_svcs"); 00572 00573 // Clear the LM_DEBUG bit from log messages if appropriate 00574 if (ACE::debug ()) 00575 ACE_Log_Msg::disable_debug_messages (); 00576 00577 int result = 0; 00578 if (ACE_Service_Repository::instance () != 0) 00579 result = ACE_Service_Repository::instance ()->fini (); 00580 00581 if (ACE::debug ()) 00582 ACE_Log_Msg::enable_debug_messages (); 00583 00584 return result; 00585 }
| ACE_Service_Gestalt * ACE_Service_Config::global | ( | void | ) | [static] |
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!
Return the global configuration instance. Allways returns the same instance
Definition at line 73 of file Service_Config.inl.
00074 { 00075 return ACE_Service_Config::singleton()->instance_.get (); 00076 }
| void ACE_Service_Config::handle_signal | ( | int | sig, | |
| siginfo_t * | , | |||
| ucontext_t * | ||||
| ) | [static] |
Handles signals to trigger reconfigurations.
Definition at line 514 of file Service_Config.cpp.
00517 { 00518 #if defined (ACE_NDEBUG) 00519 ACE_UNUSED_ARG (sig); 00520 #else /* ! ACE_NDEBUG */ 00521 ACE_ASSERT (ACE_Service_Config::signum_ == sig); 00522 #endif /* ! ACE_NDEBUG */ 00523 00524 ACE_Service_Config::reconfig_occurred_ = 1; 00525 }
| static int ACE_Service_Config::initialize | ( | const char | svc_name[], | |
| ACE_ANTI_TCHAR | parameters[] | |||
| ) | [static] |
| static int ACE_Service_Config::initialize | ( | const ACE_Service_Type * | , | |
| ACE_ANTI_TCHAR | [] | |||
| ) | [static] |
| int ACE_Service_Config::initialize | ( | const ACE_TCHAR * | svc_name, | |
| const ACE_TCHAR * | parameters | |||
| ) | [static] |
Initialize and activate a statically svc_name service.
Initialize and activate a statically linked service.
Definition at line 125 of file Service_Config.inl.
00127 { 00128 ACE_TRACE ("ACE_Service_Config::initialize"); 00129 return ACE_Service_Config::current ()->initialize (svc_name, 00130 parameters); 00131 }
| int ACE_Service_Config::initialize | ( | const ACE_Service_Type * | sr, | |
| const ACE_TCHAR * | parameters | |||
| ) | [static] |
Dynamically link the shared object file and retrieve a pointer to the designated shared object in this file.
Definition at line 136 of file Service_Config.inl.
00138 { 00139 ACE_TRACE ("ACE_Service_Config::initialize"); 00140 return ACE_Service_Config::current ()->initialize (sr, parameters); 00141 }
| int ACE_Service_Config::insert | ( | ACE_Static_Svc_Descriptor * | svc | ) | [static] |
Insert a static service descriptor for processing on open_i(). The corresponding ACE_STATIC_SVC_* macros were chaged to use this method instead of obtaining a ptr to a container. See the note on static_svcs(). Added to prevent exposing the internal storage representation of the services repository and provide a better way of debugging service loading and registration problems.
Definition at line 333 of file Service_Config.cpp.
00334 { 00335 return ACE_Service_Config::instance ()->insert (stsd); 00336 }
| ACE_Service_Gestalt * ACE_Service_Config::instance | ( | void | ) | [static] |
This is what the static service initializators are hard-wired to use, so in order to avoid interface changes this method merely forwards to ACE_Service_Config::current. This enables us to enforce which Service Gestalt is used for services registering through static initializers. Especially important for DLL-based dynamic services, which can contain their own static services and static initializers.
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.
Definition at line 84 of file Service_Config.inl.
00085 { 00086 return ACE_Service_Config::current (); 00087 }
| static int ACE_Service_Config::load_static_svcs | ( | void | ) | [static] |
| int ACE_Service_Config::open | ( | int | argc, | |
| ACE_TCHAR * | argv[], | |||
| const ACE_TCHAR * | logger_key = ACE_DEFAULT_LOGGER_KEY, |
|||
| bool | ignore_static_svcs = true, |
|||
| bool | ignore_default_svc_conf_file = false, |
|||
| bool | ignore_debug_flag = false | |||
| ) | [static] |
This is the primary entry point into the ACE_Service_Config (the constructor just handles simple initializations). It parses arguments passed in from argc and argv parameters. The arguments that are valid in a call to this method include:
chroot() to the appropriate directory. | argc | The number of commandline arguments. | |
| argv | The array with commandline arguments | |
| logger_key | Indicates where to write the logging output, which is typically either a STREAM pipe or a socket address. | |
| ignore_static_svcs | If true then static services are not loaded, otherwise, they are loaded. | |
| ignore_default_svc_conf_file | If non-0 then the svc.conf configuration file will be ignored. | |
| ignore_debug_flag | If true then the application is responsible for setting the ACE_Log_Msg::priority_mask appropriately. |
| -1 | The configuration file is not found or cannot be opened (errno is set accordingly). | |
| 0 | Success. | |
| >0 | The number of errors encountered while processing the service configuration file(s). |
Definition at line 35 of file Service_Config.inl.
00041 { 00042 ACE_TRACE ("ACE_Service_Config::open"); 00043 00044 if (singleton()->parse_args_i(argc, argv) == -1) 00045 return -1; 00046 00047 if (singleton()->open_i (argv[0], 00048 logger_key, 00049 ignore_static_svcs, 00050 ignore_default_svc_conf, 00051 ignore_debug_flag) == -1) 00052 return -1; 00053 00054 return current()->open (argc, 00055 argv, 00056 logger_key, 00057 ignore_static_svcs, 00058 ignore_default_svc_conf, 00059 ignore_debug_flag); 00060 }
| int ACE_Service_Config::open | ( | const ACE_TCHAR | program_name[], | |
| const ACE_TCHAR * | logger_key = ACE_DEFAULT_LOGGER_KEY, |
|||
| bool | ignore_static_svcs = true, |
|||
| bool | ignore_default_svc_conf_file = false, |
|||
| bool | ignore_debug_flag = false | |||
| ) | [static] |
Performs an open without parsing command-line arguments. The logger_key indicates where to write the logging output, which is typically either a STREAM pipe or a socket address. If ignore_static_svcs is true then static services are not loaded, otherwise, they are loaded. If ignore_default_svc_conf_file is non-0 then the <svc.conf> configuration file will be ignored. Returns zero upon success, -1 if the file is not found or cannot be opened (errno is set accordingly), otherwise returns the number of errors encountered loading the services in the specified svc.conf configuration file. If ignore_debug_flag is non-0 then the application is responsible for setting the ACE_Log_Msg::priority_mask appropriately.
Definition at line 12 of file Service_Config.inl.
00017 { 00018 ACE_TRACE ("ACE_Service_Config::open"); 00019 if (singleton()->open_i (program_name, 00020 logger_key, 00021 ignore_static_svcs, 00022 ignore_default_svc_conf, 00023 ignore_debug_flag) == -1) 00024 return -1; 00025 00026 return current()->open (program_name, 00027 logger_key, 00028 ignore_static_svcs, 00029 ignore_default_svc_conf, 00030 ignore_debug_flag); 00031 }
| int ACE_Service_Config::open_i | ( | const ACE_TCHAR | program_name[], | |
| const ACE_TCHAR * | logger_key, | |||
| bool | ignore_static_svcs, | |||
| bool | ignore_default_svc_conf_file, | |||
| bool | ignore_debug_flag | |||
| ) | [private, virtual] |
Performs an open without parsing command-line arguments. Implements whats different in the opening sequence for this class, as opposed to the base class.
The logger_key indicates where to write the logging output, which is typically either a STREAM pipe or a socket address. If ignore_default_svc_conf_file is non-0 then the "svc.conf" file will be ignored. If ignore_debug_flag is non-0 then the application is responsible for setting the ACE_Log_Msg::priority_mask() appropriately. Returns number of errors that occurred on failure and 0 otherwise.
Definition at line 223 of file Service_Config.cpp.
00228 { 00229 ACE_TRACE ("ACE_Service_Config::open_i"); 00230 ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1)); 00231 00232 ACE_Log_Msg *log_msg = ACE_LOG_MSG; 00233 00234 if (ACE::debug ()) 00235 ACE_DEBUG ((LM_DEBUG, 00236 ACE_TEXT ("ACE (%P|%t) SC::open_i - this=%@, opened=%d\n"), 00237 this, this->is_opened_)); 00238 00239 // Guard against reentrant processing. 00240 if (this->is_opened_) 00241 return 0; 00242 00243 this->is_opened_ = true; 00244 00245 // Check for things we need to do on a per-process basis and which 00246 // may not be safe, or wise to do an a per instance basis 00247 00248 // Become a daemon before doing anything else. 00249 if (ACE_Service_Config::be_a_daemon_) 00250 ACE::daemonize (); 00251 00252 // Write process id to file. 00253 if (this->pid_file_name_ != 0) 00254 { 00255 FILE* pidf = ACE_OS::fopen (this->pid_file_name_, 00256 ACE_TEXT("w")); 00257 00258 if (pidf != 0) 00259 { 00260 ACE_OS::fprintf (pidf, 00261 "%ld\n", 00262 static_cast<long> (ACE_OS::getpid())); 00263 ACE_OS::fclose (pidf); 00264 } 00265 } 00266 00267 u_long flags = log_msg->flags (); 00268 00269 // Only use STDERR if the caller hasn't already set the flags. 00270 if (flags == 0) 00271 flags = (u_long) ACE_Log_Msg::STDERR; 00272 00273 const ACE_TCHAR *key = logger_key; 00274 00275 if (key == 0 || ACE_OS::strcmp (key, ACE_DEFAULT_LOGGER_KEY) == 0) 00276 { 00277 // Only use the static <logger_key_> if the caller doesn't 00278 // override it in the parameter list or if the key supplied is 00279 // equal to the default static logger key. 00280 key = ACE_Service_Config::current()->logger_key_; 00281 } 00282 else 00283 { 00284 ACE_SET_BITS (flags, ACE_Log_Msg::LOGGER); 00285 } 00286 00287 if (log_msg->open (program_name, 00288 flags, 00289 key) == -1) 00290 return -1; 00291 00292 if (ACE::debug ()) 00293 ACE_DEBUG ((LM_STARTUP, 00294 ACE_TEXT ("starting up daemon %n\n"))); 00295 00296 // Initialize the Service Repository (this will still work if 00297 // user forgets to define an object of type ACE_Service_Config). 00298 ACE_Service_Repository::instance (ACE_Service_Gestalt::MAX_SERVICES); 00299 00300 // Initialize the ACE_Reactor (the ACE_Reactor should be the 00301 // same size as the ACE_Service_Repository). 00302 ACE_Reactor::instance (); 00303 00304 // There's no point in dealing with this on NT since it doesn't 00305 // really support signals very well... 00306 #if !defined (ACE_LACKS_UNIX_SIGNALS) 00307 // Only attempt to register a signal handler for positive 00308 // signal numbers. 00309 if (ACE_Service_Config::signum_ > 0) 00310 { 00311 ACE_Sig_Set ss; 00312 ss.sig_add (ACE_Service_Config::signum_); 00313 if ((ACE_Reactor::instance () != 0) && 00314 (ACE_Reactor::instance ()->register_handler 00315 (ss, ACE_Service_Config::signal_handler_) == -1)) 00316 ACE_ERROR ((LM_ERROR, 00317 ACE_TEXT ("can't register signal handler\n"))); 00318 } 00319 #endif /* ACE_LACKS_UNIX_SIGNALS */ 00320 00321 return 0; 00322 }
| int ACE_Service_Config::parse_args | ( | int | argc, | |
| ACE_TCHAR * | argv[] | |||
| ) | [static] |
Handle the command-line options intended for the ACE_Service_Config. Note that argv[0] is assumed to be the program name. The arguments that are valid in a call to this method are
Definition at line 65 of file Service_Config.inl.
00066 { 00067 return ACE_Service_Config::current ()->parse_args (argc, argv); 00068 }
| int ACE_Service_Config::parse_args_i | ( | int | argc, | |
| ACE_TCHAR * | argv[] | |||
| ) | [private, virtual] |
Implements whats different in the command line parameter processing for this class, as opposed to the base class.
Definition at line 168 of file Service_Config.cpp.
00169 { 00170 ACE_TRACE ("ACE_Service_Config::parse_args_i"); 00171 00172 // Using PERMUTE_ARGS (default) in order to have all 00173 // unrecognized options and their value arguments moved 00174 // to the end of the argument vector. We'll pick them up 00175 // after processing our options and pass them on to the 00176 // base class for further parsing. 00177 //FUZZ: disable check_for_lack_ACE_OS 00178 ACE_Get_Opt getopt (argc, 00179 argv, 00180 ACE_TEXT ("bs:p:"), 00181 1 , // Start at argv[1]. 00182 0, // Do not report errors 00183 ACE_Get_Opt::RETURN_IN_ORDER); 00184 //FUZZ: enable check_for_lack_ACE_OS 00185 00186 //FUZZ: disable check_for_lack_ACE_OS 00187 for (int c; (c = getopt ()) != -1; ) 00188 //FUZZ: enable check_for_lack_ACE_OS 00189 switch (c) 00190 { 00191 case 'p': 00192 ACE_Service_Config::pid_file_name_ = getopt.opt_arg (); 00193 break; 00194 case 'b': 00195 ACE_Service_Config::be_a_daemon_ = true; 00196 break; 00197 case 's': 00198 { 00199 // There's no point in dealing with this on NT since it 00200 // doesn't really support signals very well... 00201 #if !defined (ACE_LACKS_UNIX_SIGNALS) 00202 ACE_Service_Config::signum_ = 00203 ACE_OS::atoi (getopt.opt_arg ()); 00204 00205 if (ACE_Reactor::instance ()->register_handler 00206 (ACE_Service_Config::signum_, 00207 ACE_Service_Config::signal_handler_) == -1) 00208 ACE_ERROR_RETURN ((LM_ERROR, 00209 ACE_TEXT ("cannot obtain signal handler\n")), 00210 -1); 00211 #endif /* ACE_LACKS_UNIX_SIGNALS */ 00212 break; 00213 } 00214 default:; // unknown arguments are benign 00215 00216 } 00217 00218 return 0; 00219 } /* parse_args_i () */
| static int ACE_Service_Config::process_commandline_directives | ( | void | ) | [static] |
| int ACE_Service_Config::process_directive | ( | const ACE_Static_Svc_Descriptor & | ssd, | |
| bool | force_replace = false | |||
| ) | [static] |
Process one static service definition. Load a new static service into the ACE_Service_Repository.
| ssd | Service descriptor, see the document of ACE_Static_Svc_Descriptor for more details. | |
| force_replace | If set the new service descriptor replaces any previous instance in the ACE_Service_Repository. |
Definition at line 166 of file Service_Config.inl.
00168 { 00169 return ACE_Service_Config::current ()->process_directive (ssd, force_replace); 00170 }
| int ACE_Service_Config::process_directive | ( | const ACE_TCHAR | directive[] | ) | [static] |
Process one service configuration directive, which is passed as a string. Returns the number of errors that occurred.
Definition at line 152 of file Service_Config.inl.
00153 { 00154 return ACE_Service_Config::current ()->process_directive (directive); 00155 }
| int ACE_Service_Config::process_directives | ( | void | ) | [static] |
Process (or re-process) service configuration requests that are provided in the svc.conf file(s). Returns the number of errors that occurred.
Process service configuration requests as indicated in the queue of svc.conf files.
Definition at line 160 of file Service_Config.inl.
00161 { 00162 return ACE_Service_Config::current ()->process_directives (false); 00163 }
| static int ACE_Service_Config::process_directives_i | ( | ACE_Svc_Conf_Param * | param | ) | [static, protected] |
| int ACE_Service_Config::process_file | ( | const ACE_TCHAR | file[] | ) | [static] |
Process a file containing a list of service configuration directives.
Definition at line 145 of file Service_Config.inl.
00146 { 00147 return ACE_Service_Config::current ()->process_file (file); 00148 }
| void ACE_Service_Config::reconfig_occurred | ( | int | config_occurred | ) | [static] |
Indicate that reconfiguration occurred.
Definition at line 604 of file Service_Config.cpp.
00605 { 00606 ACE_TRACE ("ACE_Service_Config::reconfig_occurred"); 00607 ACE_Service_Config::reconfig_occurred_ = config_occurred; 00608 }
| int ACE_Service_Config::reconfig_occurred | ( | void | ) | [static] |
True if reconfiguration occurred.
Definition at line 597 of file Service_Config.cpp.
00598 { 00599 ACE_TRACE ("ACE_Service_Config::reconfig_occurred"); 00600 return ACE_Service_Config::reconfig_occurred_ != 0; 00601 }
| void ACE_Service_Config::reconfigure | ( | void | ) | [static] |
Perform the reconfiguration process.
Definition at line 529 of file Service_Config.cpp.
00530 { 00531 ACE_TRACE ("ACE_Service_Config::reconfigure"); 00532 00533 ACE_Service_Config::reconfig_occurred_ = 0; 00534 00535 if (ACE::debug ()) 00536 { 00537 #if !defined (ACE_NLOGGING) 00538 time_t t = ACE_OS::time (0); 00539 #endif /* ! ACE_NLOGGING */ 00540 if (ACE::debug ()) 00541 ACE_DEBUG ((LM_DEBUG, 00542 ACE_TEXT ("beginning reconfiguration at %s"), 00543 ACE_OS::ctime (&t))); 00544 } 00545 if (ACE_Service_Config::process_directives () == -1) 00546 ACE_ERROR ((LM_ERROR, 00547 ACE_TEXT ("%p\n"), 00548 ACE_TEXT ("process_directives"))); 00549 }
| static int ACE_Service_Config::remove | ( | const ACE_ANTI_TCHAR | svc_name[] | ) | [static] |
| int ACE_Service_Config::remove | ( | const ACE_TCHAR | svc_name[] | ) | [static] |
Totally remove svc_name from the daemon by removing it from the ACE_Reactor, and unlinking it if necessary.
Definition at line 342 of file Service_Config.cpp.
00343 { 00344 ACE_TRACE ("ACE_Service_Config::remove"); 00345 return ACE_Service_Repository::instance ()->remove (svc_name); 00346 }
| static int ACE_Service_Config::resume | ( | const ACE_ANTI_TCHAR | svc_name[] | ) | [static] |
| int ACE_Service_Config::resume | ( | const ACE_TCHAR | svc_name[] | ) | [static] |
Resume a svc_name that was previously suspended or has not yet been resumed (e.g., a static service).
Definition at line 365 of file Service_Config.cpp.
00366 { 00367 ACE_TRACE ("ACE_Service_Config::resume"); 00368 return ACE_Service_Repository::instance ()->resume (svc_name); 00369 }
| void ACE_Service_Config::signal_handler | ( | ACE_Sig_Adapter * | signal_handler | ) | [static] |
Set the signal_handler;for internal use by ACE_Object_Manager only.
Definition at line 118 of file Service_Config.inl.
00119 { 00120 signal_handler_ = signal_handler; 00121 }
| ACE_Service_Config * ACE_Service_Config::singleton | ( | void | ) | [static] |
= Static interfaces
Returns the process-wide global singleton instance. It would have been created and will be managed by the Object Manager.
Return the global configuration instance. Always returns the same instance
Definition at line 327 of file Service_Config.cpp.
00328 { 00329 return ACE_SERVICE_CONFIG_SINGLETON::instance (); 00330 }
| static int ACE_Service_Config::start_daemon | ( | void | ) | [static] |
Become a daemon.
| ACE_Service_Gestalt * ACE_Service_Config::static_svcs | ( | void | ) | [static] |
Returns a pointer to the list of statically linked services.
ACE_Service_Config::static_svcs ()->insert (...);
Definition at line 98 of file Service_Config.inl.
00099 { 00100 return ACE_Service_Config::current (); 00101 }
| static int ACE_Service_Config::suspend | ( | const ACE_ANTI_TCHAR | svc_name[] | ) | [static] |
| int ACE_Service_Config::suspend | ( | const ACE_TCHAR | svc_name[] | ) | [static] |
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...
Definition at line 355 of file Service_Config.cpp.
00356 { 00357 ACE_TRACE ("ACE_Service_Config::suspend"); 00358 return ACE_Service_Repository::instance ()->suspend (svc_name); 00359 }
friend class ACE_Service_Config_Guard [friend] |
Pointer to the Singleton (ACE_Cleanup) Gestalt instance. There is thread-specific global instance pointer, which is used to temporarily change which Gestalt instance is used for static service registrations.
A specific use case is a thread, which loads a _dynamic_ service from a DLL. If the said DLL also contains additional _static_ services, those *must* be registered with the same configuration repository as the dynamic service. Otherwise, the DLL's static services would be registered with the global Gestalt and may outlive the DLL that contains their code and perhaps the memory in which they are in. This is a problem because if the DLL gets unloaded (as it will, if it was loaded in an instance of Gestalt), the DLL's memory will be deallocated, but the global service repository will still "think" it must finalize the (DLL's) static services - with disastrous consequences, occurring in the post-main code (at_exit()). This class needs the intimate access to be able to swap the current TSS pointer for the global Gestalt.
Definition at line 642 of file Service_Config.h.
friend class ACE_Threading_Helper< ACE_Null_Mutex > [friend] |
Definition at line 646 of file Service_Config.h.
friend class ACE_Threading_Helper< ACE_Thread_Mutex > [friend] |
The helper needs intimate access (when building with no threads).
Definition at line 645 of file Service_Config.h.
Declare the dynamic allocation hooks.
Definition at line 503 of file Service_Config.h.
bool ACE_Service_Config::be_a_daemon_ = false [static, private] |
Shall we become a daemon process?
Definition at line 612 of file Service_Config.h.
The Instance, or the global (default) configuration context. The monostate would forward the calls to that instance. The TSS will point here
Definition at line 227 of file Service_Config.h.
bool ACE_Service_Config::is_opened_ [private] |
Have we called ACE_Service_Config::open() yet?
Definition at line 600 of file Service_Config.h.
ACE_SYNCH_MUTEX ACE_Service_Config::lock_ [mutable, private] |
Synchronization variable for open, etc.
Definition at line 604 of file Service_Config.h.
ACE_TCHAR * ACE_Service_Config::pid_file_name_ = 0 [static, private] |
Pathname of file to write process id.
Definition at line 615 of file Service_Config.h.
sig_atomic_t ACE_Service_Config::reconfig_occurred_ = 0 [static, private] |
True if reconfiguration occurred.
Definition at line 608 of file Service_Config.h.
ACE_Sig_Adapter * ACE_Service_Config::signal_handler_ = 0 [static, private] |
Handles the reconfiguration signals.
Definition at line 621 of file Service_Config.h.
int ACE_Service_Config::signum_ = SIGHUP [static, private] |
Number of the signal used to trigger reconfiguration.
Definition at line 618 of file Service_Config.h.
ACE_Threading_Helper<ACE_SYNCH_MUTEX> ACE_Service_Config::threadkey_ [private] |
A helper instance to manage thread-specific key creation. Dependent on the syncronization mutex ACE uses, the corresponding partial template instantiation will perform the right services that have to do with managing thread-specific storage. Note that, for single-threaded builds they would do (next to) nothing.
Definition at line 234 of file Service_Config.h.
1.6.1