#include <Service_Config.h>
Collaboration diagram for ACE_Service_Config:

Public Types | |
| enum | { MAX_SERVICES = ACE_DEFAULT_SERVICE_REPOSITORY_SIZE } |
Public Methods | |
| ACE_Service_Config (int ignore_static_svcs=1, size_t size=ACE_Service_Config::MAX_SERVICES, int signum=SIGHUP) | |
| Initialize the Service Repository. More... | |
| 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. More... | |
| void | dump (void) const |
| Dump the state of an object. More... | |
Static Public Methods | |
| int | open_i (const ACE_TCHAR program_name[], const ACE_TCHAR *logger_key=ACE_DEFAULT_LOGGER_KEY, int ignore_default_svc_conf_file=0, int ignore_debug_flag=0) |
| int | open (const ACE_TCHAR program_name[], const ACE_TCHAR *logger_key=ACE_DEFAULT_LOGGER_KEY, int ignore_static_svcs=1, int ignore_default_svc_conf_file=0, int ignore_debug_flag=0) |
| int | open (int argc, ACE_TCHAR *argv[], const ACE_TCHAR *logger_key=ACE_DEFAULT_LOGGER_KEY, int ignore_static_svcs=1, int ignore_default_svc_conf_file=0, int ignore_debug_flag=0) |
| int | close (void) |
| Tidy up and perform last rites when ACE_Service_Config is shut down. This method calls <close_svcs>. Returns 0. More... | |
| int | fini_svcs (void) |
| Perform user-specified close hooks and possibly delete all of the configured services in the <Service_Repository>. More... | |
| int | close_svcs (void) |
| int | reconfig_occurred (void) |
| True if reconfiguration occurred. More... | |
| void | reconfig_occurred (int) |
| Indicate that reconfiguration occurred. More... | |
| void | reconfigure (void) |
| Perform the reconfiguration process. More... | |
| ACE_STATIC_SVCS * | static_svcs (void) |
| Returns a pointer to the list of statically linked services. More... | |
| int | initialize (const ACE_Service_Type *, const ACE_TCHAR *parameters) |
| Dynamically link the shared object file and retrieve a pointer to the designated shared object in this file. More... | |
| int | initialize (const ACE_TCHAR *svc_name, const ACE_TCHAR *parameters) |
| Initialize and activate a statically <svc_name> service. More... | |
| int | resume (const ACE_TCHAR svc_name[]) |
| Resume a <svc_name> that was previously suspended or has not yet been resumed (e.g., a static service). More... | |
| int | suspend (const ACE_TCHAR svc_name[]) |
| int | remove (const ACE_TCHAR svc_name[]) |
| Totally remove <svc_name> from the daemon by removing it from the ACE_Reactor, and unlinking it if necessary. More... | |
| ACE_INLINE void | signal_handler (ACE_Sig_Adapter *) |
| Set the signal_handler;for internal use by ACE_Object_Manager only. More... | |
| int | process_file (const ACE_TCHAR file[]) |
| Process a file containing a list of service configuration directives. More... | |
| int | process_directive (const ACE_TCHAR directive[]) |
| Process one service configuration <directive>, which is passed as a string. Returns the number of errors that occurred. More... | |
| int | process_directive (const ACE_Static_Svc_Descriptor &ssd, int force_replace=0) |
| Process one static service definition. More... | |
| int | process_directives (void) |
| void | handle_signal (int sig, siginfo_t *, ucontext_t *) |
| Handles signals to trigger reconfigurations. More... | |
| int | parse_args (int, ACE_TCHAR *argv[]) |
| ACE_Service_Type_Impl * | create_service_type_impl (const ACE_TCHAR *name, int type, void *symbol, u_int flags, ACE_Service_Object_Exterminator gobbler) |
Public Attributes | |
| ACE_ALLOC_HOOK_DECLARE | |
| Declare the dynamic allocation hooks. More... | |
Static Protected Methods | |
| int | process_commandline_directives (void) |
| Process service configuration requests that were provided on the command-line. Returns the number of errors that occurred. More... | |
| int | process_directives_i (ACE_Svc_Conf_Param *param) |
| This is the implementation function that process_directives() and process_directive() both call. Returns the number of errors that occurred. More... | |
| int | start_daemon (void) |
| Become a daemon. More... | |
| int | load_static_svcs (void) |
| Add the default statically-linked services to the <ACE_Service_Repository>. More... | |
Static Private Methods | |
| int | init_svc_conf_file_queue (void) |
| Initialize the <svc_conf_file_queue_> if necessary. More... | |
Static Private Attributes | |
| const ACE_TCHAR * | logger_key_ = ACE_DEFAULT_LOGGER_KEY |
| Indicates where to write the logging output. This is typically either a STREAM pipe or a socket address. More... | |
| ACE_STATIC_SVCS * | static_svcs_ = 0 |
| Singleton repository of statically linked services. More... | |
| ACE_SVC_QUEUE * | svc_queue_ = 0 |
| Queue of services specified on the command-line. More... | |
| ACE_SVC_QUEUE * | svc_conf_file_queue_ = 0 |
| Queue of svc.conf files specified on the command-line. This should probably be made to handle unicode filenames... More... | |
| sig_atomic_t | reconfig_occurred_ = 0 |
| True if reconfiguration occurred. More... | |
| int | be_a_daemon_ = 0 |
| Shall we become a daemon process? More... | |
| int | no_static_svcs_ = 1 |
| Should we avoid loading the static services? More... | |
| int | signum_ = SIGHUP |
| Number of the signal used to trigger reconfiguration. More... | |
| ACE_Sig_Adapter * | signal_handler_ = 0 |
| Handles the reconfiguration signals. More... | |
| int | is_initialized_ = 0 |
The <ACE_Service_Config> uses the Monostate pattern. Therefore, you can only have one of these instantiated per-process. NOTE: the signal_handler_ static member is allocated by the <ACE_Object_Manager>. The <ACE_Service_Config> constructor uses signal_handler_. Therefore, if the program has any static <ACE_Service_Config> objects, there might be initialization order problems. They can be minimized, but not eliminated, by _not_ defining <ACE_HAS_NONSTATIC_OBJECT_MANAGER>.
Definition at line 115 of file Service_Config.h.
|
|
Definition at line 118 of file Service_Config.h.
00119 {
00120 MAX_SERVICES = ACE_DEFAULT_SERVICE_REPOSITORY_SIZE
00121 };
|
|
||||||||||||||||
|
Initialize the Service Repository.
Definition at line 122 of file Service_Config.cpp. References ACE_TRACE, ACE_Reactor::instance, ACE_Service_Repository::instance, no_static_svcs_, and signum_.
00125 {
00126 ACE_TRACE ("ACE_Service_Config::ACE_Service_Config");
00127 ACE_Service_Config::no_static_svcs_ = ignore_static_svcs;
00128 ACE_Service_Config::signum_ = signum;
00129
00130 // Initialize the Service Repository.
00131 ACE_Service_Repository::instance (ACE_static_cast (int, size));
00132
00133 // Initialize the ACE_Reactor (the ACE_Reactor should be the same
00134 // size as the ACE_Service_Repository).
00135 ACE_Reactor::instance ();
00136 }
|
|
||||||||||||
|
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 732 of file Service_Config.cpp. References ACE_ERROR, ACE_LIB_TEXT, ACE_TCHAR, ACE_TRACE, LM_ERROR, and open.
00734 {
00735 ACE_TRACE ("ACE_Service_Config::ACE_Service_Config");
00736
00737 if (this->open (program_name,
00738 logger_key) == -1
00739 && errno != ENOENT)
00740 // Only print out an error if it wasn't the svc.conf file that was
00741 // missing.
00742 ACE_ERROR ((LM_ERROR,
00743 ACE_LIB_TEXT ("%p\n"),
00744 program_name));
00745 }
|
|
|
Perform user-specified close activities and remove dynamic memory.
Definition at line 844 of file Service_Config.cpp. References ACE_TRACE.
00845 {
00846 ACE_TRACE ("ACE_Service_Config::~ACE_Service_Config");
00847 }
|
|
|
Tidy up and perform last rites when ACE_Service_Config is shut down. This method calls <close_svcs>. Returns 0.
Definition at line 790 of file Service_Config.cpp. References ACE_TRACE, close_svcs, is_initialized_, static_svcs_, and svc_conf_file_queue_. Referenced by ACE_Object_Manager::fini.
00791 {
00792 ACE_TRACE ("ACE_Service_Config::close");
00793
00794 ACE_Service_Config::is_initialized_--;
00795 if (ACE_Service_Config::is_initialized_ > 0)
00796 return 0;
00797
00798 // Delete the service repository. All the objects inside the
00799 // service repository should already have been finalized.
00800 ACE_Service_Config::close_svcs ();
00801
00802 // Delete the list fo svc.conf files
00803 delete ACE_Service_Config::svc_conf_file_queue_;
00804 ACE_Service_Config::svc_conf_file_queue_ = 0;
00805
00806 // Delete the dynamically allocated static_svcs instance.
00807 delete ACE_Service_Config::static_svcs_;
00808 ACE_Service_Config::static_svcs_ = 0;
00809
00810 return 0;
00811 }
|
|
|
Perform user-specified close hooks on all of the configured services in the <Service_Repository>, then delete the <Service_Repository> itself. Returns 0. Definition at line 814 of file Service_Config.cpp. References ACE_TRACE, and ACE_Service_Repository::close_singleton. Referenced by close.
00815 {
00816 ACE_TRACE ("ACE_Service_Config::close_svcs");
00817
00818 ACE_Service_Repository::close_singleton ();
00819
00820 return 0;
00821 }
|
|
||||||||||||||||||||||||
|
Definition at line 244 of file Service_Config.cpp. References ACE_ERROR, ACE_LIB_TEXT, ACE_NEW_RETURN, ACE_Service_Object_Exterminator, ACE_TCHAR, LM_ERROR, ACE_Service_Type::MODULE, ACE_Service_Type::SERVICE_OBJECT, and ACE_Service_Type::STREAM. Referenced by ace_yyparse, and process_directive.
00249 {
00250 ACE_Service_Type_Impl *stp = 0;
00251
00252 // Note, the only place we need to put a case statement. This is
00253 // also the place where we'd put the RTTI tests, if the compiler
00254 // actually supported them!
00255
00256 switch (type)
00257 {
00258 case ACE_Service_Type::SERVICE_OBJECT:
00259 ACE_NEW_RETURN (stp,
00260 ACE_Service_Object_Type ((ACE_Service_Object *) symbol,
00261 name, flags,
00262 gobbler),
00263 0);
00264 break;
00265 case ACE_Service_Type::MODULE:
00266 ACE_NEW_RETURN (stp,
00267 ACE_Module_Type (symbol, name, flags),
00268 0);
00269 break;
00270 case ACE_Service_Type::STREAM:
00271 ACE_NEW_RETURN (stp,
00272 ACE_Stream_Type (symbol, name, flags),
00273 0);
00274 break;
00275 default:
00276 ACE_ERROR ((LM_ERROR,
00277 ACE_LIB_TEXT ("unknown case\n")));
00278 break;
00279 }
00280 return stp;
00281
00282 }
|
|
|
Dump the state of an object.
Definition at line 31 of file Service_Config.cpp. References ACE_TRACE.
00032 {
00033 ACE_TRACE ("ACE_Service_Config::dump");
00034 }
|
|
|
Perform user-specified close hooks and possibly delete all of the configured services in the <Service_Repository>.
Definition at line 824 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.
00825 {
00826 ACE_TRACE ("ACE_Service_Config::fini_svcs");
00827
00828 // Clear the LM_DEBUG bit from log messages if appropriate
00829 if (ACE::debug ())
00830 ACE_Log_Msg::disable_debug_messages ();
00831
00832 int result = 0;
00833 if (ACE_Service_Repository::instance () != 0)
00834 result = ACE_Service_Repository::instance ()->fini ();
00835
00836 if (ACE::debug ())
00837 ACE_Log_Msg::enable_debug_messages ();
00838
00839 return result;
00840 }
|
|
||||||||||||||||
|
Handles signals to trigger reconfigurations.
Definition at line 750 of file Service_Config.cpp. References ACE_ASSERT, reconfig_occurred_, signum_, and ucontext_t. Referenced by ACE_Object_Manager::init.
00753 {
00754 #if defined (ACE_NDEBUG)
00755 ACE_UNUSED_ARG (sig);
00756 #else /* ! ACE_NDEBUG */
00757 ACE_ASSERT (ACE_Service_Config::signum_ == sig);
00758 #endif /* ! ACE_NDEBUG */
00759
00760 ACE_Service_Config::reconfig_occurred_ = 1;
00761 }
|
|
|
Initialize the <svc_conf_file_queue_> if necessary.
Definition at line 139 of file Service_Config.cpp. References ACE_NEW_RETURN, and svc_conf_file_queue_. Referenced by open_i, and parse_args.
00140 {
00141 if (ACE_Service_Config::svc_conf_file_queue_ == 0)
00142 ACE_NEW_RETURN (ACE_Service_Config::svc_conf_file_queue_,
00143 ACE_SVC_QUEUE,
00144 -1);
00145 return 0;
00146 }
|
|
||||||||||||
|
Initialize and activate a statically <svc_name> service.
Definition at line 287 of file Service_Config.cpp. References ACE_DEBUG, ACE_ERROR, ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_TCHAR, ACE_TRACE, ACE_Service_Type::active, ACE_ARGV::argc, ACE_ARGV::argv, ACE::debug, ACE_Service_Repository::find, ACE_Service_Type_Impl::init, ACE_Service_Repository::instance, LM_DEBUG, LM_ERROR, ACE_Service_Repository::remove, and ACE_Service_Type::type.
00289 {
00290 ACE_TRACE ("ACE_Service_Config::initialize");
00291 ACE_ARGV args (parameters);
00292 ACE_Service_Type *srp = 0;
00293
00294 if (ACE::debug ())
00295 ACE_DEBUG ((LM_DEBUG,
00296 ACE_LIB_TEXT ("opening static service %s\n"),
00297 svc_name));
00298
00299 if (ACE_Service_Repository::instance ()->find
00300 (svc_name,
00301 (const ACE_Service_Type **) &srp) == -1)
00302 ACE_ERROR_RETURN ((LM_ERROR,
00303 ACE_LIB_TEXT ("%s not found\n"),
00304 svc_name),
00305 -1);
00306 else if (srp->type ()->init (args.argc (),
00307 args.argv ()) == -1)
00308 {
00309 // Remove this entry.
00310 ACE_ERROR ((LM_ERROR,
00311 ACE_LIB_TEXT ("static initialization failed, %p\n"),
00312 svc_name));
00313 ACE_Service_Repository::instance ()->remove (svc_name);
00314 return -1;
00315 }
00316 else
00317 {
00318 srp->active (1);
00319 return 0;
00320 }
00321 }
|
|
||||||||||||
|
Dynamically link the shared object file and retrieve a pointer to the designated shared object in this file.
Definition at line 327 of file Service_Config.cpp. References ACE_DEBUG, ACE_ERROR, ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_TCHAR, ACE_TRACE, ACE_ARGV::argc, ACE_ARGV::argv, ACE::debug, ACE_Service_Type_Impl::init, ACE_Service_Repository::insert, ACE_Service_Repository::instance, LM_DEBUG, LM_ERROR, ACE_Service_Type::name, and ACE_Service_Type::type. Referenced by ACE_Static_Node::apply, ACE_Dynamic_Node::apply, and ACE_Stream_Node::apply.
00329 {
00330 ACE_TRACE ("ACE_Service_Config::initialize");
00331 ACE_ARGV args (parameters);
00332
00333 if (ACE::debug ())
00334 ACE_DEBUG ((LM_DEBUG,
00335 ACE_LIB_TEXT ("opening dynamic service %s\n"),
00336 sr->name ()));
00337
00338 if (sr->type ()->init (args.argc (),
00339 args.argv ()) == -1)
00340 {
00341 ACE_ERROR ((LM_ERROR,
00342 ACE_LIB_TEXT ("dynamic initialization failed for %s\n"),
00343 sr->name ()));
00344 return -1;
00345 }
00346 else
00347 {
00348 if (ACE_Service_Repository::instance ()->insert (sr) == -1)
00349 ACE_ERROR_RETURN ((LM_ERROR,
00350 ACE_LIB_TEXT ("insertion failed, %p\n"),
00351 sr->name ()),
00352 -1);
00353 return 0;
00354 }
00355 }
|
|
|
Add the default statically-linked services to the <ACE_Service_Repository>.
Definition at line 587 of file Service_Config.cpp. References ACE_TRACE, ACE_Unbounded_Set_Iterator::advance, ACE_Unbounded_Set_Iterator::next, process_directive, and static_svcs. Referenced by open_i.
00588 {
00589 ACE_TRACE ("ACE_Service_Config::load_static_svcs");
00590
00591 ACE_Static_Svc_Descriptor **ssdp = 0;
00592 ACE_STATIC_SVCS &svcs = *ACE_Service_Config::static_svcs ();
00593
00594 for (ACE_STATIC_SVCS_ITERATOR iter (svcs);
00595 iter.next (ssdp) != 0;
00596 iter.advance ())
00597 {
00598 ACE_Static_Svc_Descriptor *ssd = *ssdp;
00599
00600 if (ACE_Service_Config::process_directive (*ssd, 1) == -1)
00601 return -1;
00602 }
00603 return 0;
00604 }
|
|
||||||||||||||||||||||||||||
|
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:
Definition at line 26 of file Service_Config.i. References ACE_TCHAR, ACE_TRACE, no_static_svcs_, open_i, and parse_args.
00032 {
00033 ACE_TRACE ("ACE_Service_Config::open");
00034 ACE_Service_Config::no_static_svcs_ = ignore_static_svcs;
00035
00036 if (ACE_Service_Config::parse_args (argc,
00037 argv) == -1)
00038 return -1;
00039 else
00040 return ACE_Service_Config::open_i (argv[0],
00041 logger_key,
00042 ignore_default_svc_conf,
00043 ignore_debug_flag);
00044 }
|
|
||||||||||||||||||||||||
|
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 1 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 10 of file Service_Config.i. References ACE_TCHAR, ACE_TRACE, no_static_svcs_, and open_i. Referenced by ACE_Service_Config.
00015 {
00016 ACE_TRACE ("ACE_Service_Config::open");
00017 ACE_Service_Config::no_static_svcs_ = ignore_static_svcs;
00018
00019 return ACE_Service_Config::open_i (program_name,
00020 logger_key,
00021 ignore_default_svc_conf,
00022 ignore_debug_flag);
00023 }
|
|
||||||||||||||||||||
|
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_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 609 of file Service_Config.cpp. References ACE_DEBUG, ACE_DEFAULT_LOGGER_KEY, ACE_DEFAULT_SVC_CONF, ACE_ERROR, ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_LOG_MSG, ACE_SET_BITS, ACE_TCHAR, ACE_TRACE, ACE_TString, ACE::debug, ACE_Log_Msg::disable_debug_messages, ACE_Log_Msg::enable_debug_messages, ACE_Unbounded_Queue< ACE_TString >::enqueue_tail, ACE_Log_Msg::flags, init_svc_conf_file_queue, ACE_Reactor::instance, ACE_Service_Repository::instance, ACE_Unbounded_Queue< ACE_TString >::is_empty, is_initialized_, LM_ERROR, LM_STARTUP, load_static_svcs, ACE_Log_Msg::LOGGER, logger_key_, MAX_SERVICES, no_static_svcs_, ACE_Log_Msg::open, ACE_Log_Msg::priority_mask, ACE_Log_Msg::PROCESS, process_commandline_directives, process_directives, ACE_Reactor::register_handler, signal_handler_, signum_, start_daemon, ACE_Log_Msg::STDERR, ACE_OS_String::strcmp, svc_conf_file_queue_, and ACE_Log_Msg::THREAD. Referenced by open.
00613 {
00614 int result = 0;
00615 ACE_TRACE ("ACE_Service_Config::open_i");
00616 ACE_Log_Msg *log_msg = ACE_LOG_MSG;
00617
00618 // Record the current log setting upon entering this thread.
00619 u_long old_process_mask = log_msg->priority_mask
00620 (ACE_Log_Msg::PROCESS);
00621 u_long old_thread_mask = log_msg->priority_mask
00622 (ACE_Log_Msg::THREAD);
00623
00624 if (ACE_Service_Config::is_initialized_ != 0)
00625 // Guard against reentrant processing!
00626 return 0;
00627 else
00628 ACE_Service_Config::is_initialized_++;
00629
00630 if (ACE_Service_Config::init_svc_conf_file_queue () == -1)
00631 return -1;
00632 else if (!ignore_default_svc_conf_file
00633 && ACE_Service_Config::svc_conf_file_queue_->is_empty ()
00634 // Load the default "svc.conf" entry here if there weren't
00635 // overriding -f arguments in <parse_args>.
00636 && ACE_Service_Config::svc_conf_file_queue_->enqueue_tail
00637 (ACE_TString (ACE_DEFAULT_SVC_CONF)) == -1)
00638 ACE_ERROR_RETURN ((LM_ERROR,
00639 ACE_LIB_TEXT ("%p\n"),
00640 "enqueue_tail"),
00641 -1);
00642
00643 if (ignore_debug_flag == 0)
00644 {
00645 // If -d was included as a startup parameter, the user wants debug
00646 // information printed during service initialization.
00647 if (ACE::debug ())
00648 ACE_Log_Msg::enable_debug_messages ();
00649 else
00650 // The user has requested no debugging info.
00651 ACE_Log_Msg::disable_debug_messages ();
00652 }
00653
00654 // Become a daemon before doing anything else.
00655 if (ACE_Service_Config::be_a_daemon_)
00656 ACE_Service_Config::start_daemon ();
00657
00658 u_long flags = log_msg->flags ();
00659
00660 if (flags == 0)
00661 // Only use STDERR if the caller hasn't already set the flags.
00662 flags = (u_long) ACE_Log_Msg::STDERR;
00663
00664 const ACE_TCHAR *key = logger_key;
00665
00666 if (key == 0 || ACE_OS::strcmp (key, ACE_DEFAULT_LOGGER_KEY) == 0)
00667 // Only use the static <logger_key_> if the caller doesn't
00668 // override it in the parameter list or if the key supplied is
00669 // equal to the default static logger key.
00670 key = ACE_Service_Config::logger_key_;
00671 else
00672 ACE_SET_BITS (flags, ACE_Log_Msg::LOGGER);
00673
00674 if (log_msg->open (program_name,
00675 flags,
00676 key) == -1)
00677 result = -1;
00678 else
00679 {
00680 if (ACE::debug ())
00681 ACE_DEBUG ((LM_STARTUP,
00682 ACE_LIB_TEXT ("starting up daemon %n\n")));
00683
00684 // Initialize the Service Repository (this will still work if
00685 // user forgets to define an object of type ACE_Service_Config).
00686 ACE_Service_Repository::instance (ACE_Service_Config::MAX_SERVICES);
00687
00688 // Initialize the ACE_Reactor (the ACE_Reactor should be the
00689 // same size as the ACE_Service_Repository).
00690 ACE_Reactor::instance ();
00691
00692 // There's no point in dealing with this on NT since it doesn't
00693 // really support signals very well...
00694 #if !defined (ACE_LACKS_UNIX_SIGNALS)
00695 // @@ This really ought to be a Singleton.
00696 if (ACE_Reactor::instance ()->register_handler
00697 (ACE_Service_Config::signum_,
00698 ACE_Service_Config::signal_handler_) == -1)
00699 ACE_ERROR ((LM_ERROR,
00700 ACE_LIB_TEXT ("can't register signal handler\n")));
00701 #endif /* ACE_LACKS_UNIX_SIGNALS */
00702
00703 // See if we need to load the static services.
00704 if (ACE_Service_Config::no_static_svcs_ == 0
00705 && ACE_Service_Config::load_static_svcs () == -1)
00706 result = -1;
00707 else
00708 {
00709 if (ACE_Service_Config::process_commandline_directives () == -1)
00710 result = -1;
00711 else
00712 result = ACE_Service_Config::process_directives ();
00713 }
00714 }
00715
00716 {
00717 // Make sure to save/restore errno properly.
00718 ACE_Errno_Guard error (errno);
00719
00720 if (ignore_debug_flag == 0)
00721 {
00722 // Reset debugging back to the way it was when we came into
00723 // into <open_i>.
00724 log_msg->priority_mask (old_process_mask, ACE_Log_Msg::PROCESS);
00725 log_msg->priority_mask (old_thread_mask, ACE_Log_Msg::THREAD);
00726 }
00727 }
00728
00729 return result;
00730 }
|
|
||||||||||||
|
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 152 of file Service_Config.cpp. References ACE_DEBUG, ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_NEW_RETURN, ACE_TCHAR, ACE_TRACE, ACE_TString, ACE_OS::atoi, be_a_daemon_, ACE::debug, ACE_Unbounded_Queue< ACE_TString >::enqueue_tail, init_svc_conf_file_queue, ACE_Reactor::instance, LM_DEBUG, LM_ERROR, logger_key_, no_static_svcs_, ACE_Get_Opt::opt_arg, ACE_Reactor::register_handler, signal_handler_, signum_, svc_conf_file_queue_, and svc_queue_. Referenced by open.
00153 {
00154 ACE_TRACE ("ACE_Service_Config::parse_args");
00155 ACE_Get_Opt getopt (argc,
00156 argv,
00157 ACE_LIB_TEXT ("bdf:k:nys:S:"),
00158 1); // Start at argv[1].
00159
00160 if (ACE_Service_Config::init_svc_conf_file_queue () == -1)
00161 return -1;
00162
00163 for (int c; (c = getopt ()) != -1; )
00164 switch (c)
00165 {
00166 case 'b':
00167 ACE_Service_Config::be_a_daemon_ = 1;
00168 break;
00169 case 'd':
00170 ACE::debug (1);
00171 break;
00172 case 'f':
00173 if (ACE_Service_Config::svc_conf_file_queue_->enqueue_tail
00174 (ACE_TString (getopt.opt_arg ())) == -1)
00175 ACE_ERROR_RETURN ((LM_ERROR,
00176 ACE_LIB_TEXT ("%p\n"),
00177 "enqueue_tail"),
00178 -1);
00179 break;
00180 case 'k':
00181 ACE_Service_Config::logger_key_ = getopt.opt_arg ();
00182 break;
00183 case 'n':
00184 ACE_Service_Config::no_static_svcs_ = 1;
00185 break;
00186 case 'y':
00187 ACE_Service_Config::no_static_svcs_ = 0;
00188 break;
00189 case 's':
00190 {
00191 // There's no point in dealing with this on NT since it
00192 // doesn't really support signals very well...
00193 #if !defined (ACE_LACKS_UNIX_SIGNALS)
00194 ACE_Service_Config::signum_ =
00195 ACE_OS::atoi (getopt.opt_arg ());
00196
00197 if (ACE_Reactor::instance ()->register_handler
00198 (ACE_Service_Config::signum_,
00199 ACE_Service_Config::signal_handler_) == -1)
00200 ACE_ERROR_RETURN ((LM_ERROR,
00201 ACE_LIB_TEXT ("cannot obtain signal handler\n")),
00202 -1);
00203 #endif /* ACE_LACKS_UNIX_SIGNALS */
00204 break;
00205 }
00206 case 'S':
00207 if (ACE_Service_Config::svc_queue_ == 0)
00208 ACE_NEW_RETURN (ACE_Service_Config::svc_queue_,
00209 ACE_SVC_QUEUE,
00210 -1);
00211 if (ACE_Service_Config::svc_queue_->enqueue_tail
00212 (ACE_TString (getopt.opt_arg ())) == -1)
00213 ACE_ERROR_RETURN ((LM_ERROR,
00214 ACE_LIB_TEXT ("%p\n"),
00215 "enqueue_tail"),
00216 -1);
00217 break;
00218 default:
00219 if (ACE::debug () > 0)
00220 ACE_DEBUG ((LM_DEBUG,
00221 ACE_LIB_TEXT ("%c is not a ACE_Service_Config option\n"),
00222 c));
00223 }
00224
00225 return 0;
00226 }
|
|
|
Process service configuration requests that were provided on the command-line. Returns the number of errors that occurred.
Definition at line 515 of file Service_Config.cpp. References ACE_ERROR, ACE_LIB_TEXT, ACE_Unbounded_Queue_Iterator::advance, ACE_String_Base< char >::fast_rep, LM_ERROR, ACE_Unbounded_Queue_Iterator::next, process_directive, and svc_queue_. Referenced by open_i.
00516 {
00517 int result = 0;
00518
00519 if (ACE_Service_Config::svc_queue_ != 0)
00520 {
00521 ACE_TString *sptr = 0;
00522 ACE_SVC_QUEUE &queue = *ACE_Service_Config::svc_queue_;
00523
00524 for (ACE_SVC_QUEUE_ITERATOR iter (queue);
00525 iter.next (sptr) != 0;
00526 iter.advance ())
00527 {
00528 // Process just a single directive.
00529 if (ACE_Service_Config::process_directive (sptr->fast_rep ()) != 0)
00530 {
00531 ACE_ERROR ((LM_ERROR,
00532 ACE_LIB_TEXT ("%p\n"),
00533 ACE_LIB_TEXT ("process_directive")));
00534 result = -1;
00535 }
00536 }
00537
00538 delete ACE_Service_Config::svc_queue_;
00539 ACE_Service_Config::svc_queue_ = 0;
00540 }
00541
00542 return result;
00543 }
|
|
||||||||||||
|
Process one static service definition. Load a new static service into the ACE_Service_Repository.
Definition at line 546 of file Service_Config.cpp. References ACE_NEW_RETURN, ACE_Service_Object_Exterminator, ACE_Static_Svc_Descriptor::active_, ACE_Static_Svc_Descriptor::alloc_, create_service_type_impl, ACE_Service_Repository::find, ACE_Static_Svc_Descriptor::flags_, ACE_Service_Repository::insert, ACE_Service_Repository::instance, ACE_Static_Svc_Descriptor::name_, and ACE_Static_Svc_Descriptor::type_.
00548 {
00549 if (!force_replace)
00550 {
00551 if (ACE_Service_Repository::instance ()->find (ssd.name_,
00552 0, 0) >= 0)
00553 {
00554 // The service is already there, just return
00555 return 0;
00556 }
00557 }
00558
00559 ACE_Service_Object_Exterminator gobbler;
00560 void *sym = (ssd.alloc_)(&gobbler);
00561
00562 ACE_Service_Type_Impl *stp =
00563 ACE_Service_Config::create_service_type_impl (ssd.name_,
00564 ssd.type_,
00565 sym,
00566 ssd.flags_,
00567 gobbler);
00568 if (stp == 0)
00569 return 0;
00570
00571
00572 ACE_Service_Type *service_type;
00573 ACE_NEW_RETURN (service_type,
00574 ACE_Service_Type (ssd.name_,
00575 stp,
00576 0,
00577 ssd.active_),
00578 -1);
00579
00580 return ACE_Service_Repository::instance ()->insert (service_type);
00581 }
|
|
|
Process one service configuration <directive>, which is passed as a string. Returns the number of errors that occurred.
Definition at line 450 of file Service_Config.cpp. References ACE_DEBUG, ACE_LIB_TEXT, ACE_TCHAR, ACE_TRACE, ACE::debug, ACE_Auto_Basic_Ptr::get, LM_DEBUG, and process_directives_i. Referenced by load_static_svcs, process_commandline_directives, and ACE_Service_Manager::process_request.
00451 {
00452 ACE_TRACE ("ACE_Service_Config::process_directive");
00453
00454 if (ACE::debug ())
00455 ACE_DEBUG ((LM_DEBUG,
00456 ACE_LIB_TEXT ("Service_Config::process_directive - %s\n"),
00457 directive));
00458
00459 #if (ACE_USES_CLASSIC_SVC_CONF == 1)
00460 ACE_UNUSED_ARG (directive);
00461
00462 ACE_Svc_Conf_Param d (directive);
00463
00464 int result = ACE_Service_Config::process_directives_i (&d);
00465
00466 return result;
00467 #else
00468 ACE_DLL dll;
00469
00470 auto_ptr<ACE_XML_Svc_Conf>
00471 xml_svc_conf (ACE_Service_Config::get_xml_svc_conf (dll));
00472
00473 if (xml_svc_conf.get () == 0)
00474 return -1;
00475
00476 return xml_svc_conf->parse_string (directive);
00477 #endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */
00478 }
|
|
|
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 483 of file Service_Config.cpp. References ACE_TRACE, ACE_Unbounded_Queue_Iterator::advance, ACE_String_Base< char >::fast_rep, ACE_Unbounded_Queue_Iterator::next, process_file, and svc_conf_file_queue_. Referenced by open_i, and reconfigure.
00484 {
00485 ACE_TRACE ("ACE_Service_Config::process_directives");
00486
00487 int result = 0;
00488
00489 if (ACE_Service_Config::svc_conf_file_queue_ != 0)
00490 {
00491 ACE_TString *sptr = 0;
00492 ACE_SVC_QUEUE &queue = *ACE_Service_Config::svc_conf_file_queue_;
00493
00494 // Iterate through all the svc.conf files.
00495 for (ACE_SVC_QUEUE_ITERATOR iter (queue);
00496 iter.next (sptr) != 0;
00497 iter.advance ())
00498 {
00499 int r = ACE_Service_Config::process_file (sptr->fast_rep ());
00500
00501 if (r < 0)
00502 {
00503 result = r;
00504 break;
00505 }
00506
00507 result += r;
00508 }
00509 }
00510
00511 return result;
00512 }
|
|
|
This is the implementation function that process_directives() and process_directive() both call. Returns the number of errors that occurred.
Definition at line 359 of file Service_Config.cpp. References ace_yyparse, and ACE_Svc_Conf_Param::yyerrno. Referenced by process_directive, and process_file.
00360 {
00361 // AC 970827 Skip the heap check because yacc allocates a buffer
00362 // here which will be reported as a memory leak for some reason.
00363
00364
00365 ACE_NO_HEAP_CHECK ::ace_yyparse (param);
00366
00367 if (param->yyerrno > 0)
00368 {
00369 // This is a hack, better errors should be provided...
00370 errno = EINVAL;
00371 return param->yyerrno;
00372 }
00373 else
00374 return 0;
00375 }
|
|
|
Process a file containing a list of service configuration directives.
Definition at line 404 of file Service_Config.cpp. References ACE_DEBUG, ACE_LIB_TEXT, ACE_TCHAR, ACE_TRACE, ACE::debug, ACE_OS::fclose, ACE_OS::fopen, ACE_Auto_Basic_Ptr::get, LM_DEBUG, and process_directives_i. Referenced by process_directives.
00405 {
00406 ACE_TRACE ("ACE_Service_Config::process_file");
00407
00408 #if (ACE_USES_CLASSIC_SVC_CONF == 1)
00409 int result = 0;
00410
00411 FILE *fp = ACE_OS::fopen (file,
00412 ACE_LIB_TEXT ("r"));
00413
00414 if (fp == 0)
00415 {
00416 // Invalid svc.conf file. We'll report it here and break out of
00417 // the method.
00418 if (ACE::debug ())
00419 ACE_DEBUG ((LM_DEBUG,
00420 ACE_LIB_TEXT ("%p\n"),
00421 file));
00422
00423 errno = ENOENT;
00424 result = -1;
00425 }
00426 else
00427 {
00428 ACE_Svc_Conf_Param f (fp);
00429
00430 // Keep track of the number of errors.
00431 result = ACE_Service_Config::process_directives_i (&f);
00432
00433 (void) ACE_OS::fclose (fp);
00434 }
00435 return result;
00436 #else
00437 ACE_DLL dll;
00438
00439 auto_ptr<ACE_XML_Svc_Conf>
00440 xml_svc_conf (ACE_Service_Config::get_xml_svc_conf (dll));
00441
00442 if (xml_svc_conf.get () == 0)
00443 return -1;
00444
00445 return xml_svc_conf->parse_file (file);
00446 #endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */
00447 }
|
|
|
Indicate that reconfiguration occurred.
Definition at line 860 of file Service_Config.cpp. References ACE_TRACE, and reconfig_occurred_.
00861 {
00862 ACE_TRACE ("ACE_Service_Config::reconfig_occurred");
00863 ACE_Service_Config::reconfig_occurred_ = config_occurred;
00864 }
|
|
|
True if reconfiguration occurred.
Definition at line 853 of file Service_Config.cpp. References ACE_TRACE, and reconfig_occurred_. Referenced by ACE_Reactor::check_reconfiguration, ACE_Proactor::check_reconfiguration, and ACE_Service_Manager::reconfigure_services.
00854 {
00855 ACE_TRACE ("ACE_Service_Config::reconfig_occurred");
00856 return ACE_Service_Config::reconfig_occurred_ != 0;
00857 }
|
|
|
Perform the reconfiguration process.
Definition at line 766 of file Service_Config.cpp. References ACE_DEBUG, ACE_ERROR, ACE_LIB_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, and ACE_Proactor::check_reconfiguration.
00767 {
00768 ACE_TRACE ("ACE_Service_Config::reconfigure");
00769
00770 ACE_Service_Config::reconfig_occurred_ = 0;
00771
00772 if (ACE::debug ())
00773 {
00774 #if !defined (ACE_NLOGGING)
00775 time_t t = ACE_OS::time (0);
00776 #endif /* ! ACE_NLOGGING */
00777 if (ACE::debug ())
00778 ACE_DEBUG ((LM_DEBUG,
00779 ACE_LIB_TEXT ("beginning reconfiguration at %s"),
00780 ACE_OS::ctime (&t)));
00781 }
00782 if (ACE_Service_Config::process_directives () == -1)
00783 ACE_ERROR ((LM_ERROR,
00784 ACE_LIB_TEXT ("%p\n"),
00785 ACE_LIB_TEXT ("process_directives")));
00786 }
|
|
|
Totally remove <svc_name> from the daemon by removing it from the ACE_Reactor, and unlinking it if necessary.
Definition at line 88 of file Service_Config.cpp. References ACE_TCHAR, ACE_TRACE, ACE_Service_Repository::instance, and ACE_Service_Repository::remove. Referenced by ACE_Remove_Node::apply.
00089 {
00090 ACE_TRACE ("ACE_Service_Config::remove");
00091 return ACE_Service_Repository::instance ()->remove (svc_name);
00092 }
|
|
|
Resume a <svc_name> that was previously suspended or has not yet been resumed (e.g., a static service).
Definition at line 111 of file Service_Config.cpp. References ACE_TCHAR, ACE_TRACE, ACE_Service_Repository::instance, and ACE_Service_Repository::resume. Referenced by ACE_Resume_Node::apply.
00112 {
00113 ACE_TRACE ("ACE_Service_Config::resume");
00114 return ACE_Service_Repository::instance ()->resume (svc_name);
00115 }
|
|
|
Set the signal_handler;for internal use by ACE_Object_Manager only.
Definition at line 63 of file Service_Config.i. References signal_handler_. Referenced by ACE_Object_Manager::init.
00064 {
00065 signal_handler_ = signal_handler;
00066 }
|
|
|
Become a daemon.
Definition at line 869 of file Service_Config.cpp. References ACE_TRACE, and ACE::daemonize. Referenced by open_i.
00870 {
00871 ACE_TRACE ("ACE_Service_Config::start_daemon");
00872 return ACE::daemonize ();
00873 }
|
|
|
Returns a pointer to the list of statically linked services.
Definition at line 75 of file Service_Config.cpp. References ACE_NEW_RETURN, and static_svcs_. Referenced by ACE_Object_Manager_Preallocations::ACE_Object_Manager_Preallocations, load_static_svcs, and ACE_Static_Function_Node::symbol.
00076 {
00077 if (ACE_Service_Config::static_svcs_ == 0)
00078 ACE_NEW_RETURN (ACE_Service_Config::static_svcs_,
00079 ACE_STATIC_SVCS,
00080 0);
00081 return ACE_Service_Config::static_svcs_;
00082 }
|
|
|
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 101 of file Service_Config.cpp. References ACE_TCHAR, ACE_TRACE, ACE_Service_Repository::instance, and ACE_Service_Repository::suspend. Referenced by ACE_Suspend_Node::apply.
00102 {
00103 ACE_TRACE ("ACE_Service_Config::suspend");
00104 return ACE_Service_Repository::instance ()->suspend (svc_name);
00105 }
|
|
|
Declare the dynamic allocation hooks.
Definition at line 309 of file Service_Config.h. |
|
|
Shall we become a daemon process?
Definition at line 52 of file Service_Config.cpp. Referenced by parse_args. |
|
|
Keep track of whether the <ACE_Service_Config> is already initialized. If so, we can't allow <yyparse> to be called since it's not reentrant. This variable is incremented by the <ACE_Service_Config::open> method and decremented by the <ACE_Service_Config::close> method. Definition at line 66 of file Service_Config.cpp. |
|
|
Indicates where to write the logging output. This is typically either a STREAM pipe or a socket address.
Definition at line 60 of file Service_Config.cpp. Referenced by open_i, and parse_args. |
|
|
Should we avoid loading the static services?
Definition at line 53 of file Service_Config.cpp. Referenced by ACE_Service_Config, open, open_i, and parse_args. |
|
|
True if reconfiguration occurred.
Definition at line 49 of file Service_Config.cpp. Referenced by handle_signal, reconfig_occurred, and reconfigure. |
|
|
Handles the reconfiguration signals.
Definition at line 46 of file Service_Config.cpp. Referenced by open_i, parse_args, and signal_handler. |
|
|
Number of the signal used to trigger reconfiguration.
Definition at line 56 of file Service_Config.cpp. Referenced by ACE_Service_Config, handle_signal, open_i, and parse_args. |
|
|
Singleton repository of statically linked services.
Definition at line 70 of file Service_Config.cpp. Referenced by close, and static_svcs. |
|
|
Queue of svc.conf files specified on the command-line. This should probably be made to handle unicode filenames... @ Definition at line 72 of file Service_Config.cpp. Referenced by close, init_svc_conf_file_queue, open_i, parse_args, and process_directives. |
|
|
Queue of services specified on the command-line.
Definition at line 71 of file Service_Config.cpp. Referenced by parse_args, and process_commandline_directives. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002