#include <Service_Config.h>
Collaboration diagram for ACE_Service_Config:
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) |
Perform user-specified close activities and remove dynamic memory. | |
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 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_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? | |
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 > |
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 381 of file Service_Config.cpp.
References ACE_NEW_NORETURN, ACE_TRACE, instance_, is_opened_, signum_, and threadkey_.
00384 { 00385 ACE_TRACE ("ACE_Service_Config::ACE_Service_Config"); 00386 00387 // TODO: Need to find a more customizable way of instantiating the 00388 // gestalt but perhaps we should leave this out untill such 00389 // customizations are identified. 00390 ACE_Service_Gestalt* tmp = 0; 00391 ACE_NEW_NORETURN (tmp, 00392 ACE_Service_Gestalt (size, false, ignore_static_svcs)); 00393 00394 this->is_opened_ = false; 00395 this->instance_ = tmp; 00396 this->threadkey_.set (tmp); 00397 00398 ACE_Service_Config::signum_ = signum; 00399 }
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 401 of file Service_Config.cpp.
References ACE_ERROR, ACE_NEW_NORETURN, ACE_TEXT, ACE_TRACE, ACE_Service_Repository::DEFAULT_SIZE, instance_, is_opened_, LM_ERROR, and threadkey_.
00403 { 00404 ACE_TRACE ("ACE_Service_Config::ACE_Service_Config"); 00405 00406 // TODO: Need to find a more customizable way of instantiating the 00407 // gestalt but perhaps we should leave this out untill such 00408 // customizations are identified. 00409 ACE_Service_Gestalt* tmp = 0; 00410 ACE_NEW_NORETURN (tmp, 00411 ACE_Service_Gestalt (ACE_Service_Repository::DEFAULT_SIZE, false)); 00412 00413 this->is_opened_ = false; 00414 this->instance_ = tmp; 00415 this->threadkey_.set (tmp); 00416 00417 if (this->open (program_name, 00418 logger_key) == -1 && errno != ENOENT) 00419 { 00420 // Only print out an error if it wasn't the svc.conf file that was 00421 // missing. 00422 ACE_ERROR ((LM_ERROR, 00423 ACE_TEXT ("(%P|%t) SC failed to open: %p\n"), 00424 program_name)); 00425 } 00426 }
ACE_Service_Config::~ACE_Service_Config | ( | void | ) | [virtual] |
Perform user-specified close activities and remove dynamic memory.
Perform user-specified close activities and remove dynamic memory.
Definition at line 601 of file Service_Config.cpp.
References ACE_TRACE.
00602 { 00603 ACE_TRACE ("ACE_Service_Config::~ACE_Service_Config"); 00604 }
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 566 of file Service_Config.cpp.
References ACE_Unmanaged_Singleton< TYPE, ACE_LOCK >::close(), ACE_Service_Repository::close_singleton(), instance_, and singleton().
Referenced by ACE_Object_Manager::fini().
00567 { 00568 ACE_Service_Config::singleton ()->instance_->close (); 00569 00570 // Delete the service repository. All the objects inside the 00571 // service repository should already have been finalized. 00572 ACE_Service_Repository::close_singleton (); 00573 00574 // Do away with the singleton ACE_Service_Config (calls dtor) 00575 ACE_SERVICE_CONFIG_SINGLETON::close (); 00576 00577 return 0; 00578 }
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 484 of file Service_Config.cpp.
References ACE_ERROR, ACE_NEW_RETURN, ACE_TEXT, LM_ERROR, ACE_Service_Type::MODULE, ACE_Service_Type::SERVICE_OBJECT, and ACE_Service_Type::STREAM.
Referenced by ACE_Service_Gestalt::process_directive_i().
00489 { 00490 ACE_Service_Type_Impl *stp = 0; 00491 00492 // Note, the only place we need to put a case statement. This is 00493 // also the place where we'd put the RTTI tests, if the compiler 00494 // actually supported them! 00495 00496 switch (type) 00497 { 00498 case ACE_Service_Type::SERVICE_OBJECT: 00499 ACE_NEW_RETURN (stp, 00500 ACE_Service_Object_Type ((ACE_Service_Object *) symbol, 00501 name, flags, 00502 gobbler), 00503 0); 00504 break; 00505 case ACE_Service_Type::MODULE: 00506 ACE_NEW_RETURN (stp, 00507 ACE_Module_Type (symbol, name, flags), 00508 0); 00509 break; 00510 case ACE_Service_Type::STREAM: 00511 ACE_NEW_RETURN (stp, 00512 ACE_Stream_Type (symbol, name, flags), 00513 0); 00514 break; 00515 default: 00516 ACE_ERROR ((LM_ERROR, 00517 ACE_TEXT ("unknown case\n"))); 00518 break; 00519 } 00520 return stp; 00521 00522 }
ACE_Service_Gestalt * ACE_Service_Config::current | ( | void | ) | [static] |
Accessor for the "current" service gestalt
Definition at line 436 of file Service_Config.cpp.
References global(), singleton(), and threadkey_.
Referenced by ACE_Dynamic_Service_Dependency::ACE_Dynamic_Service_Dependency(), ACE_Service_Config_Guard::ACE_Service_Config_Guard(), ACE_Base_Thread_Adapter::inherit_log_msg(), initialize(), instance(), ACE_Dynamic_Service_Base::instance(), ACE_Thread_Adapter::invoke(), open(), open_i(), parse_args(), process_directive(), process_directives(), process_file(), static_svcs(), and ACE_Service_Config_Guard::~ACE_Service_Config_Guard().
00437 { 00438 void* temp = ACE_Service_Config::singleton()->threadkey_.get (); 00439 if (temp == 0) { 00440 00441 // The most likely reason is that the current thread was spawned 00442 // by some native primitive, like pthreads or Windows API - not 00443 // from ACE. This is perfectly legal for callers who are not, or 00444 // do not need to be ACE-aware. Such callers must have no 00445 // expectation that the pluggable, multi-context configuration 00446 // support will work - they would always get the global context, 00447 // because at this point there is no information what the "parent" 00448 // thread's configuration context was. 00449 00450 temp = global(); 00451 singleton()->threadkey_.set (temp); 00452 } 00453 00454 return static_cast<ACE_Service_Gestalt*> (temp); 00455 00456 00457 }
void ACE_Service_Config::current | ( | ACE_Service_Gestalt * | ) | [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 461 of file Service_Config.cpp.
References singleton(), and threadkey_.
00462 { 00463 ACE_Service_Config::singleton()->threadkey_.set (newcurrent); 00464 }
void ACE_Service_Config::dump | ( | void | ) | const |
Dump the state of an object.
Definition at line 160 of file Service_Config.cpp.
References ACE_TRACE.
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 582 of file Service_Config.cpp.
References ACE_TRACE, ACE::debug(), ACE_Log_Msg::disable_debug_messages(), ACE_Log_Msg::enable_debug_messages(), ACE_Service_Repository::fini(), and ACE_Service_Repository::instance().
Referenced by ACE_Object_Manager::fini().
00583 { 00584 ACE_TRACE ("ACE_Service_Config::fini_svcs"); 00585 00586 // Clear the LM_DEBUG bit from log messages if appropriate 00587 if (ACE::debug ()) 00588 ACE_Log_Msg::disable_debug_messages (); 00589 00590 int result = 0; 00591 if (ACE_Service_Repository::instance () != 0) 00592 result = ACE_Service_Repository::instance ()->fini (); 00593 00594 if (ACE::debug ()) 00595 ACE_Log_Msg::enable_debug_messages (); 00596 00597 return result; 00598 }
ACE_INLINE 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!
Definition at line 69 of file Service_Config.inl.
References ACE_Intrusive_Auto_Ptr< X >::get(), instance_, and singleton().
Referenced by current(), ACE_Dynamic_Service_Base::find_i(), ACE_Service_Gestalt::initialize(), and ACE_Thread_Adapter::invoke().
00070 { 00071 return ACE_Service_Config::singleton()->instance_.get (); 00072 }
void ACE_Service_Config::handle_signal | ( | int | sig, | |
siginfo_t * | , | |||
ucontext_t * | ||||
) | [static] |
Handles signals to trigger reconfigurations.
Definition at line 527 of file Service_Config.cpp.
References ACE_ASSERT, reconfig_occurred_, and signum_.
Referenced by ACE_Object_Manager::init().
00530 { 00531 #if defined (ACE_NDEBUG) 00532 ACE_UNUSED_ARG (sig); 00533 #else /* ! ACE_NDEBUG */ 00534 ACE_ASSERT (ACE_Service_Config::signum_ == sig); 00535 #endif /* ! ACE_NDEBUG */ 00536 00537 ACE_Service_Config::reconfig_occurred_ = 1; 00538 }
ACE_INLINE int ACE_Service_Config::initialize | ( | const ACE_TCHAR * | svc_name, | |
const ACE_TCHAR * | parameters | |||
) | [static] |
Initialize and activate a statically svc_name service.
Definition at line 121 of file Service_Config.inl.
References ACE_TRACE, current(), and ACE_Service_Gestalt::initialize().
00123 { 00124 ACE_TRACE ("ACE_Service_Config::initialize"); 00125 return ACE_Service_Config::current ()->initialize (svc_name, 00126 parameters); 00127 }
ACE_INLINE int ACE_Service_Config::initialize | ( | const ACE_Service_Type * | , | |
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 132 of file Service_Config.inl.
References ACE_TRACE, current(), and ACE_Service_Gestalt::initialize().
00134 { 00135 ACE_TRACE ("ACE_Service_Config::initialize"); 00136 return ACE_Service_Config::current ()->initialize (sr, parameters); 00137 }
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 342 of file Service_Config.cpp.
References ACE_Service_Gestalt::insert(), and instance().
00343 { 00344 return ACE_Service_Config::instance ()->insert (stsd); 00345 }
ACE_INLINE 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.
Definition at line 80 of file Service_Config.inl.
References current().
Referenced by insert().
00081 { 00082 return ACE_Service_Config::current (); 00083 }
static int ACE_Service_Config::load_static_svcs | ( | void | ) | [static] |
ACE_INLINE 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.
References ACE_TRACE, current(), ACE_Service_Gestalt::open(), open_i(), and singleton().
00041 { 00042 ACE_TRACE ("ACE_Service_Config::open"); 00043 if (singleton()->open_i (argv[0], 00044 logger_key, 00045 ignore_static_svcs, 00046 ignore_default_svc_conf, 00047 ignore_debug_flag) == -1) 00048 return -1; 00049 00050 return current()->open (argc, 00051 argv, 00052 logger_key, 00053 ignore_static_svcs, 00054 ignore_default_svc_conf, 00055 ignore_debug_flag); 00056 }
ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE 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.
References ACE_TRACE, current(), ACE_Service_Gestalt::open(), open_i(), and singleton().
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 236 of file Service_Config.cpp.
References ACE_DEBUG, ACE_DEFAULT_LOGGER_KEY, ACE_ERROR, ACE_GUARD_RETURN, ACE_LOG_MSG, ACE_SET_BITS, ACE_SYNCH_MUTEX, ACE_TEXT, ACE_TRACE, be_a_daemon_, current(), ACE::daemonize(), ACE::debug(), ACE_OS::fclose(), ACE_Log_Msg::flags(), ACE_OS::fopen(), ACE_OS::fprintf(), ACE_OS::getpid(), ACE_Reactor::instance(), ACE_Service_Repository::instance(), is_opened_, LM_DEBUG, LM_ERROR, LM_STARTUP, ACE_Log_Msg::LOGGER, ACE_Service_Gestalt::logger_key_, ACE_Service_Gestalt::MAX_SERVICES, ACE_Log_Msg::open(), ACE_Sig_Set::sig_add(), signal_handler_, signum_, ACE_Log_Msg::STDERR, and ACE_OS::strcmp().
Referenced by open().
00241 { 00242 ACE_TRACE ("ACE_Service_Config::open_i"); 00243 ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1)); 00244 00245 ACE_Log_Msg *log_msg = ACE_LOG_MSG; 00246 00247 if (ACE::debug ()) 00248 ACE_DEBUG ((LM_DEBUG, 00249 ACE_TEXT ("ACE (%P|%t) SC::open_i - this=%@, opened=%d\n"), 00250 this, this->is_opened_)); 00251 00252 // Guard against reentrant processing. 00253 if (this->is_opened_) 00254 return 0; 00255 00256 this->is_opened_ = true; 00257 00258 // Check for things we need to do on a per-process basis and which 00259 // may not be safe, or wise to do an a per instance basis 00260 00261 // Become a daemon before doing anything else. 00262 if (ACE_Service_Config::be_a_daemon_) 00263 ACE::daemonize (); 00264 00265 // Write process id to file. 00266 if (this->pid_file_name_ != 0) 00267 { 00268 FILE* pidf = ACE_OS::fopen (this->pid_file_name_, 00269 ACE_TEXT("w")); 00270 00271 if (pidf != 0) 00272 { 00273 ACE_OS::fprintf (pidf, 00274 "%ld\n", 00275 static_cast<long> (ACE_OS::getpid())); 00276 ACE_OS::fclose (pidf); 00277 } 00278 } 00279 00280 u_long flags = log_msg->flags (); 00281 00282 // Only use STDERR if the caller hasn't already set the flags. 00283 if (flags == 0) 00284 flags = (u_long) ACE_Log_Msg::STDERR; 00285 00286 const ACE_TCHAR *key = logger_key; 00287 00288 if (key == 0 || ACE_OS::strcmp (key, ACE_DEFAULT_LOGGER_KEY) == 0) 00289 // Only use the static <logger_key_> if the caller doesn't 00290 // override it in the parameter list or if the key supplied is 00291 // equal to the default static logger key. 00292 key = ACE_Service_Config::current()->logger_key_; 00293 else 00294 ACE_SET_BITS (flags, ACE_Log_Msg::LOGGER); 00295 00296 if (log_msg->open (program_name, 00297 flags, 00298 key) == -1) 00299 return -1; 00300 00301 if (ACE::debug ()) 00302 ACE_DEBUG ((LM_STARTUP, 00303 ACE_TEXT ("starting up daemon %n\n"))); 00304 00305 // Initialize the Service Repository (this will still work if 00306 // user forgets to define an object of type ACE_Service_Config). 00307 ACE_Service_Repository::instance (ACE_Service_Gestalt::MAX_SERVICES); 00308 00309 // Initialize the ACE_Reactor (the ACE_Reactor should be the 00310 // same size as the ACE_Service_Repository). 00311 ACE_Reactor::instance (); 00312 00313 // There's no point in dealing with this on NT since it doesn't 00314 // really support signals very well... 00315 #if !defined (ACE_LACKS_UNIX_SIGNALS) 00316 // Only attempt to register a signal handler for positive 00317 // signal numbers. 00318 if (ACE_Service_Config::signum_ > 0) 00319 { 00320 ACE_Sig_Set ss; 00321 ss.sig_add (ACE_Service_Config::signum_); 00322 if ((ACE_Reactor::instance () != 0) && 00323 (ACE_Reactor::instance ()->register_handler 00324 (ss, ACE_Service_Config::signal_handler_) == -1)) 00325 ACE_ERROR ((LM_ERROR, 00326 ACE_TEXT ("can't register signal handler\n"))); 00327 } 00328 #endif /* ACE_LACKS_UNIX_SIGNALS */ 00329 00330 return 0; 00331 }
ACE_INLINE int ACE_Service_Config::parse_args | ( | int | , | |
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 61 of file Service_Config.inl.
References current(), and ACE_Service_Gestalt::parse_args().
00062 { 00063 return ACE_Service_Config::current ()->parse_args (argc, argv); 00064 }
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.
References ACE_ERROR_RETURN, ACE_TEXT, ACE_TRACE, ACE_ARGV_T< CHAR_TYPE >::add(), ACE_ARGV_T< CHAR_TYPE >::argc(), ACE_ARGV_T< CHAR_TYPE >::argv(), ACE_OS::atoi(), be_a_daemon_, ACE_OS::getopt(), ACE_Reactor::instance(), instance_, LM_ERROR, pid_file_name_, ACE_Get_Opt::RETURN_IN_ORDER, signal_handler_, and signum_.
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 // Keep a list of all unknown arguments, begin with the 00187 // executable's name 00188 ACE_ARGV superargv; 00189 superargv.add (argv[0]); 00190 00191 //FUZZ: disable check_for_lack_ACE_OS 00192 for (int c; (c = getopt ()) != -1; ) 00193 //FUZZ: enable check_for_lack_ACE_OS 00194 switch (c) 00195 { 00196 case 'p': 00197 ACE_Service_Config::pid_file_name_ = getopt.opt_arg (); 00198 break; 00199 case 'b': 00200 ACE_Service_Config::be_a_daemon_ = true; 00201 break; 00202 case 's': 00203 { 00204 // There's no point in dealing with this on NT since it 00205 // doesn't really support signals very well... 00206 #if !defined (ACE_LACKS_UNIX_SIGNALS) 00207 ACE_Service_Config::signum_ = 00208 ACE_OS::atoi (getopt.opt_arg ()); 00209 00210 if (ACE_Reactor::instance ()->register_handler 00211 (ACE_Service_Config::signum_, 00212 ACE_Service_Config::signal_handler_) == -1) 00213 ACE_ERROR_RETURN ((LM_ERROR, 00214 ACE_TEXT ("cannot obtain signal handler\n")), 00215 -1); 00216 #endif /* ACE_LACKS_UNIX_SIGNALS */ 00217 break; 00218 } 00219 default: 00220 superargv.add (argv[getopt.opt_ind () - 1], true); 00221 } 00222 00223 // Collect any argumets that were left 00224 for (int c = getopt.opt_ind (); c < argc; ++c) 00225 superargv.add (argv[c-1], true); 00226 00227 bool ignore_default_svc_conf_file = false; 00228 return instance_->parse_args_i (superargv.argc (), 00229 superargv.argv (), 00230 ignore_default_svc_conf_file); 00231 00232 } /* parse_args_i () */
static int ACE_Service_Config::process_commandline_directives | ( | void | ) | [static] |
ACE_INLINE 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 162 of file Service_Config.inl.
References current(), and ACE_Service_Gestalt::process_directive().
00164 { 00165 return ACE_Service_Config::current ()->process_directive (ssd, force_replace); 00166 }
ACE_INLINE 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 148 of file Service_Config.inl.
References current(), and ACE_Service_Gestalt::process_directive().
Referenced by ACE::Monitor_Control::Monitor_Admin_Manager::Initializer(), and ACE_Service_Manager::process_request().
00149 { 00150 return ACE_Service_Config::current ()->process_directive (directive); 00151 }
ACE_INLINE 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.
Definition at line 156 of file Service_Config.inl.
References current(), and ACE_Service_Gestalt::process_directives().
Referenced by reconfigure().
00157 { 00158 return ACE_Service_Config::current ()->process_directives (false); 00159 }
static int ACE_Service_Config::process_directives_i | ( | ACE_Svc_Conf_Param * | param | ) | [static, protected] |
ACE_INLINE int ACE_Service_Config::process_file | ( | const ACE_TCHAR | file[] | ) | [static] |
Process a file containing a list of service configuration directives.
Definition at line 141 of file Service_Config.inl.
References current(), and ACE_Service_Gestalt::process_file().
00142 { 00143 return ACE_Service_Config::current ()->process_file (file); 00144 }
void ACE_Service_Config::reconfig_occurred | ( | int | ) | [static] |
Indicate that reconfiguration occurred.
Definition at line 617 of file Service_Config.cpp.
References ACE_TRACE, and reconfig_occurred_.
00618 { 00619 ACE_TRACE ("ACE_Service_Config::reconfig_occurred"); 00620 ACE_Service_Config::reconfig_occurred_ = config_occurred; 00621 }
int ACE_Service_Config::reconfig_occurred | ( | void | ) | [static] |
True if reconfiguration occurred.
Definition at line 610 of file Service_Config.cpp.
References ACE_TRACE, and reconfig_occurred_.
Referenced by ACE_Reactor::check_reconfiguration(), and ACE_Service_Manager::reconfigure_services().
00611 { 00612 ACE_TRACE ("ACE_Service_Config::reconfig_occurred"); 00613 return ACE_Service_Config::reconfig_occurred_ != 0; 00614 }
void ACE_Service_Config::reconfigure | ( | void | ) | [static] |
Perform the reconfiguration process.
Definition at line 542 of file Service_Config.cpp.
References ACE_DEBUG, ACE_ERROR, ACE_TEXT, ACE_TRACE, ACE_OS::ctime(), ACE::debug(), LM_DEBUG, LM_ERROR, process_directives(), reconfig_occurred_, and ACE_OS::time().
Referenced by ACE_Reactor::check_reconfiguration().
00543 { 00544 ACE_TRACE ("ACE_Service_Config::reconfigure"); 00545 00546 ACE_Service_Config::reconfig_occurred_ = 0; 00547 00548 if (ACE::debug ()) 00549 { 00550 #if !defined (ACE_NLOGGING) 00551 time_t t = ACE_OS::time (0); 00552 #endif /* ! ACE_NLOGGING */ 00553 if (ACE::debug ()) 00554 ACE_DEBUG ((LM_DEBUG, 00555 ACE_TEXT ("beginning reconfiguration at %s"), 00556 ACE_OS::ctime (&t))); 00557 } 00558 if (ACE_Service_Config::process_directives () == -1) 00559 ACE_ERROR ((LM_ERROR, 00560 ACE_TEXT ("%p\n"), 00561 ACE_TEXT ("process_directives"))); 00562 }
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 351 of file Service_Config.cpp.
References ACE_TRACE, ACE_Service_Repository::instance(), and ACE_Service_Repository::remove().
00352 { 00353 ACE_TRACE ("ACE_Service_Config::remove"); 00354 return ACE_Service_Repository::instance ()->remove (svc_name); 00355 }
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 374 of file Service_Config.cpp.
References ACE_TRACE, ACE_Service_Repository::instance(), and ACE_Service_Repository::resume().
00375 { 00376 ACE_TRACE ("ACE_Service_Config::resume"); 00377 return ACE_Service_Repository::instance ()->resume (svc_name); 00378 }
ACE_INLINE void ACE_Service_Config::signal_handler | ( | ACE_Sig_Adapter * | ) | [static] |
Set the signal_handler;for internal use by ACE_Object_Manager only.
Definition at line 114 of file Service_Config.inl.
References signal_handler_.
Referenced by ACE_Object_Manager::init().
00115 { 00116 signal_handler_ = signal_handler; 00117 }
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.
Definition at line 336 of file Service_Config.cpp.
References ACE_Unmanaged_Singleton< TYPE, ACE_LOCK >::instance().
Referenced by close(), current(), ACE_Threading_Helper< ACE_Null_Mutex >::get(), global(), and open().
00337 { 00338 return ACE_SERVICE_CONFIG_SINGLETON::instance (); 00339 }
static int ACE_Service_Config::start_daemon | ( | void | ) | [static] |
Become a daemon.
ACE_INLINE ACE_Service_Gestalt * ACE_Service_Config::static_svcs | ( | void | ) | [static] |
Returns a pointer to the list of statically linked services.
Definition at line 94 of file Service_Config.inl.
References current().
Referenced by ACE_Object_Manager_Preallocations::ACE_Object_Manager_Preallocations().
00095 { 00096 return ACE_Service_Config::current (); 00097 }
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 364 of file Service_Config.cpp.
References ACE_TRACE, ACE_Service_Repository::instance(), and ACE_Service_Repository::suspend().
00365 { 00366 ACE_TRACE ("ACE_Service_Config::suspend"); 00367 return ACE_Service_Repository::instance ()->suspend (svc_name); 00368 }
friend class ACE_Service_Config_Guard [friend] |
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.
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.
Referenced by open_i(), and parse_args_i().
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.
Referenced by ACE_Service_Config(), close(), ACE_Threading_Helper< ACE_Null_Mutex >::get(), global(), and parse_args_i().
bool ACE_Service_Config::is_opened_ [private] |
Have we called ACE_Service_Config::open() yet?
Definition at line 600 of file Service_Config.h.
Referenced by ACE_Service_Config(), and open_i().
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.
Referenced by parse_args_i().
sig_atomic_t ACE_Service_Config::reconfig_occurred_ = 0 [static, private] |
True if reconfiguration occurred.
Definition at line 608 of file Service_Config.h.
Referenced by handle_signal(), reconfig_occurred(), and reconfigure().
ACE_Sig_Adapter * ACE_Service_Config::signal_handler_ = 0 [static, private] |
Handles the reconfiguration signals.
Definition at line 621 of file Service_Config.h.
Referenced by open_i(), parse_args_i(), and signal_handler().
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.
Referenced by ACE_Service_Config(), handle_signal(), open_i(), and parse_args_i().
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.
Referenced by ACE_Service_Config(), and current().