diff options
Diffstat (limited to 'externals/ace/Service_Gestalt.cpp')
-rw-r--r-- | externals/ace/Service_Gestalt.cpp | 95 |
1 files changed, 41 insertions, 54 deletions
diff --git a/externals/ace/Service_Gestalt.cpp b/externals/ace/Service_Gestalt.cpp index 47ea3d1e81b..8b3f8b8ed3c 100644 --- a/externals/ace/Service_Gestalt.cpp +++ b/externals/ace/Service_Gestalt.cpp @@ -1,4 +1,4 @@ -// $Id: Service_Gestalt.cpp 91158 2010-07-21 15:54:12Z mesnier_p $ +// $Id: Service_Gestalt.cpp 89501 2010-03-17 08:59:56Z vzykov $ #include "ace/Svc_Conf.h" #include "ace/Get_Opt.h" @@ -31,7 +31,7 @@ ACE_RCSID (ace, Service_Gestalt, - "$Id: Service_Gestalt.cpp 91158 2010-07-21 15:54:12Z mesnier_p $") + "$Id: Service_Gestalt.cpp 89501 2010-03-17 08:59:56Z vzykov $") ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -259,6 +259,32 @@ ACE_Service_Gestalt::init_i (void) if (init_svc_conf_file_queue () == -1) return -1; + if ( svc_conf_file_queue_->is_empty ()) + { + // Check if the default file exists before attempting to queue it + // for processing + FILE *fp = ACE_OS::fopen (ACE_DEFAULT_SVC_CONF, + ACE_TEXT ("r")); + bool skip_static_svcs = (fp == 0); + if (fp != 0) + ACE_OS::fclose (fp); + + if (!skip_static_svcs) { + // Load the default "svc.conf" entry here if there weren't + // overriding -f arguments in <parse_args>. + if (svc_conf_file_queue_->enqueue_tail + (ACE_TString (ACE_DEFAULT_SVC_CONF)) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("enqueuing ") + ACE_DEFAULT_SVC_CONF + ACE_TEXT(" file")), + -1); + } + } + } + return 0; } @@ -1060,62 +1086,19 @@ ACE_Service_Gestalt::open_i (const ACE_TCHAR program_name[], ACE_Log_Msg::disable_debug_messages (); } - if (!ignore_default_svc_conf_file) - { - bool add_default = true; - bool has_files = this->svc_conf_file_queue_ && - !this->svc_conf_file_queue_->is_empty (); - bool has_cmdline = this->svc_queue_ && !this->svc_queue_->is_empty (); - if (has_files || has_cmdline) - { - // check if default file is already listed - ACE_TString *sptr = 0; - ACE_TString default_svc_conf (ACE_DEFAULT_SVC_CONF); - - for (ACE_SVC_QUEUE_ITERATOR iter (*this->svc_conf_file_queue_); - iter.next (sptr) != 0 && add_default; - iter.advance ()) - { - add_default = (*sptr != default_svc_conf); - } - - if (add_default) - { - FILE *fp = ACE_OS::fopen (ACE_DEFAULT_SVC_CONF, ACE_TEXT ("r")); - if (fp != 0) - ACE_OS::fclose(fp); - else - add_default = false; - - } - } - - // Load the default "svc.conf" entry. here if there weren't - // overriding -f arguments in <parse_args>. - if (add_default && svc_conf_file_queue_->enqueue_head - (ACE_TString (ACE_DEFAULT_SVC_CONF)) == -1) - { - errno = ENOENT; - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("enqueuing ") - ACE_DEFAULT_SVC_CONF - ACE_TEXT(" file")), - -1); - } - } - // See if we need to load the static services. if (this->no_static_svcs_ == 0 && this->load_static_svcs () == -1) result = -1; else { - result = this->process_directives (); - if (result != -1 || errno == ENOENT) + if (this->process_directives (ignore_default_svc_conf_file) == -1) + result = -1; + else result = this->process_commandline_directives (); } + // Reset debugging back to the way it was when we came into // into <open_i>. { @@ -1247,16 +1230,17 @@ ACE_Service_Gestalt::parse_args_i (int argc, // Process service configuration directives from the files queued for // processing int -ACE_Service_Gestalt::process_directives (bool ) +ACE_Service_Gestalt::process_directives (bool ignore_default_svc_conf_file) { ACE_TRACE ("ACE_Service_Gestalt::process_directives"); + if (this->svc_conf_file_queue_ == 0 - || this->svc_conf_file_queue_->is_empty ()) - { - return 0; - } + || this->svc_conf_file_queue_->is_empty ()) + return 0; ACE_TString *sptr = 0; + ACE_TString default_svc_conf (ACE_DEFAULT_SVC_CONF); + int failed = 0; // Iterate through all the svc.conf files. @@ -1264,6 +1248,9 @@ ACE_Service_Gestalt::process_directives (bool ) iter.next (sptr) != 0; iter.advance ()) { + if (*sptr == default_svc_conf && ignore_default_svc_conf_file) + continue; + int result = this->process_file (sptr->fast_rep ()); if (result < 0) return result; |