diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1998-10-17 04:01:21 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1998-10-17 04:01:21 +0000 |
commit | 84aa8aa34396ba30ea70bd5c5507eb09e1a5b371 (patch) | |
tree | caaac5252e05a699408dea67fb86ece15703e6e0 | |
parent | a1deb82c52f4af0dff11aafda638cca29ffb6f83 (diff) | |
download | ATCD-84aa8aa34396ba30ea70bd5c5507eb09e1a5b371.tar.gz |
*** empty log message ***
-rw-r--r-- | ChangeLog-98b | 11 | ||||
-rw-r--r-- | ace/Service_Config.cpp | 99 | ||||
-rw-r--r-- | ace/Service_Config.h | 12 |
3 files changed, 91 insertions, 31 deletions
diff --git a/ChangeLog-98b b/ChangeLog-98b index 43df7730b48..c07b47855cc 100644 --- a/ChangeLog-98b +++ b/ChangeLog-98b @@ -1,5 +1,16 @@ Fri Oct 16 15:45:08 1998 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> + * ace/Service_Config.cpp (parse_args): Modified the -S option to + enqueue the directives in FIFO order rather than in LIFO order. + It's more intuitive to process them in the order they are + received! + + * ace/Service_Config: It's now possible to give multiple -f + options to the Service Configurator and it will open multiple + files and process each one in the order specified in argv. + Thanks to David O'Farrell <dave.ofarrell@aersoft.ie> for + suggesting this. + * ace: Replaced all #if !defined (ACE_FOO_H) with #ifndef ACE_FOO_H since many C++ preprocessors can recognize this idiom and optimize for it. diff --git a/ace/Service_Config.cpp b/ace/Service_Config.cpp index 82eb7a5a137..49c188a98a6 100644 --- a/ace/Service_Config.cpp +++ b/ace/Service_Config.cpp @@ -57,9 +57,6 @@ int ACE_Service_Config::signum_ = SIGHUP; // Name of file used to store messages. LPCTSTR ACE_Service_Config::logger_key_ = ACE_DEFAULT_LOGGER_KEY; -// Name of the service configuration file. -const ASYS_TCHAR *ACE_Service_Config::service_config_file_ = ASYS_TEXT (ACE_DEFAULT_SVC_CONF); - // The ACE_Service_Manager static service object is now defined // by the ACE_Object_Manager, in Object_Manager.cpp. @@ -67,6 +64,7 @@ const ASYS_TCHAR *ACE_Service_Config::service_config_file_ = ASYS_TEXT (ACE_DEFA ACE_STATIC_SVCS *ACE_Service_Config::static_svcs_ = 0; ACE_SVC_QUEUE *ACE_Service_Config::svc_queue_ = 0; +ACE_SVC_QUEUE *ACE_Service_Config::svc_conf_file_queue_ = 0; ACE_STATIC_SVCS * ACE_Service_Config::static_svcs (void) @@ -199,6 +197,19 @@ ACE_Service_Config::parse_args (int argc, ASYS_TCHAR *argv[]) ASYS_TEXT ("bdf:k:nys:S:"), 1); // Start at argv[1]. + if (ACE_Service_Config::svc_conf_file_queue_ == 0) + { + ACE_NEW (ACE_Service_Config::svc_conf_file_queue_, + ACE_SVC_QUEUE); + + // Load the default "svc.conf" entry here. + if (ACE_Service_Config::svc_queue_->enqueue_tail + (ACE_CString (ACE_DEFAULT_SVC_CONF)) == -1) + ACE_ERROR ((LM_ERROR, + ASYS_TEXT ("%p\n"), + "enqueue_tail")); + } + for (int c; (c = getopt ()) != -1; ) switch (c) { @@ -209,10 +220,15 @@ ACE_Service_Config::parse_args (int argc, ASYS_TCHAR *argv[]) ACE::debug (1); break; case 'f': - ACE_Service_Config::service_config_file_ = getopt.optarg; + if (ACE_Service_Config::svc_queue_->enqueue_tail + (ACE_CString (getopt.optarg)) == -1) + ACE_ERROR ((LM_ERROR, + ASYS_TEXT ("%p\n"), + "enqueue_tail")); break; case 'k': - ACE_Service_Config::logger_key_ = ACE_WIDE_STRING (getopt.optarg); + ACE_Service_Config::logger_key_ = + ACE_WIDE_STRING (getopt.optarg); break; case 'n': ACE_Service_Config::no_static_svcs_ = 1; @@ -225,7 +241,8 @@ ACE_Service_Config::parse_args (int argc, ASYS_TCHAR *argv[]) // There's no point in dealing with this on NT since it // doesn't really support signals very well... #if !defined (ACE_LACKS_UNIX_SIGNALS) - ACE_Service_Config::signum_ = ACE_OS::atoi (getopt.optarg); + ACE_Service_Config::signum_ = + ACE_OS::atoi (getopt.optarg); if (ACE_Reactor::instance ()->register_handler (ACE_Service_Config::signum_, @@ -237,13 +254,14 @@ ACE_Service_Config::parse_args (int argc, ASYS_TCHAR *argv[]) } case 'S': if (ACE_Service_Config::svc_queue_ == 0) - ACE_Service_Config::svc_queue_ = new ACE_SVC_QUEUE; + ACE_NEW (ACE_Service_Config::svc_queue_, + ACE_SVC_QUEUE); - if (ACE_Service_Config::svc_queue_->enqueue_head + if (ACE_Service_Config::svc_queue_->enqueue_tail (ACE_CString (getopt.optarg)) == -1) ACE_ERROR ((LM_ERROR, ASYS_TEXT ("%p\n"), - "enqueue_head")); + "enqueue_tail")); break; default: ACE_ERROR ((LM_ERROR, @@ -268,13 +286,13 @@ ACE_Service_Config::initialize (const ASYS_TCHAR svc_name[], ASYS_TEXT ("opening static service %s\n"), svc_name)); - if (ACE_Service_Repository::instance ()->find (svc_name, - (const ACE_Service_Type **) &srp) == -1) + if (ACE_Service_Repository::instance ()->find + (svc_name, + (const ACE_Service_Type **) &srp) == -1) ACE_ERROR_RETURN ((LM_ERROR, ASYS_TEXT ("%s not found\n"), svc_name), -1); - else if (srp->type ()->init (args.argc (), args.argv ()) == -1) ACE_ERROR_RETURN ((LM_ERROR, @@ -368,27 +386,57 @@ ACE_Service_Config::process_directive (const ASYS_TCHAR directive[]) return result; } -// Process service configuration requests as indicated in the -// <service_config_file>. +// Process service configuration requests as indicated in the queue of +// svc.conf files. int ACE_Service_Config::process_directives (void) { ACE_TRACE ("ACE_Service_Config::process_directives"); - FILE *fp = ACE_OS::fopen (ACE_Service_Config::service_config_file_, - ASYS_TEXT ("r")); + int result = 0; - if (fp == 0) - { - errno = ENOENT; - return -1; // No service configuration file - } - else + if (ACE_Service_Config::svc_conf_file_queue_ != 0) { - ace_yyrestart (fp); - return ACE_Service_Config::process_directives_i (); + ACE_CString *sptr = 0; + ACE_SVC_QUEUE &queue = *ACE_Service_Config::svc_conf_file_queue_; + + // Iterate through all the svc.conf files. + for (ACE_SVC_QUEUE_ITERATOR iter (queue); + iter.next (sptr) != 0; + iter.advance ()) + { + // @@ We can remove the ASYS_WIDE_STRING stuff when this is + // defined as an ACE_WString... + FILE *fp = ACE_OS::fopen (ASYS_WIDE_STRING (sptr->fast_rep ()), + ASYS_TEXT ("r")); + + if (fp == 0) + { + // Invalid svc.conf file. We'll report it her and keep + // track of this and return -1 when the method finishes. + // all the files. + ACE_ERROR ((LM_ERROR, + ASYS_TEXT ("%p\n"), + // @@ Beware of the WString here... Not + // sure how to fix this with %p... + ASYS_TEXT (sptr->fast_rep ()))); + result = -1; + } + else + { + ace_yyrestart (fp); + return ACE_Service_Config::process_directives_i (); + } + } + + delete ACE_Service_Config::svc_conf_file_queue_; + ACE_Service_Config::svc_conf_file_queue_ = 0; } + + if (result == -1) + errno = ENOENT; + return result; } int @@ -406,7 +454,8 @@ ACE_Service_Config::process_commandline_directives (void) iter.advance ()) { // Process just a single directive. - if (ACE_Service_Config::process_directive (ASYS_WIDE_STRING (sptr->fast_rep ())) == -1) + if (ACE_Service_Config::process_directive + (ASYS_WIDE_STRING (sptr->fast_rep ())) == -1) { ACE_ERROR ((LM_ERROR, ASYS_TEXT ("%p\n"), diff --git a/ace/Service_Config.h b/ace/Service_Config.h index f0430bb60dc..6d08cfc23df 100644 --- a/ace/Service_Config.h +++ b/ace/Service_Config.h @@ -290,8 +290,7 @@ public: protected: static int process_directives (void); // Process service configuration requests that are provided in the - // <service_config_file>. Returns the number of errors that - // occurred. + // svc.config file(s). Returns the number of errors that occurred. static int process_commandline_directives (void); // Process service configuration requests that were provided on the @@ -315,9 +314,6 @@ protected: // <ACE_Service_Repository>. private: - static const ASYS_TCHAR *service_config_file_; - // Name of service configuration file. - static LPCTSTR logger_key_; // Where to write the logging output. @@ -325,7 +321,11 @@ private: // Singleton repository of statically linked services. static ACE_SVC_QUEUE *svc_queue_; - // Queue of services requested on the command-line. + // Queue of services specified on the command-line. + + static ACE_SVC_QUEUE *svc_conf_file_queue_; + // Queue of svc.conf files specified on the command-line. + // @@ This should probably be made to handle unicode filenames... static sig_atomic_t reconfig_occurred_; // True if reconfiguration occurred. |