Exemplo n.º 1
0
int
ACE_Service_Gestalt::process_commandline_directives (void)
{
  int result = 0;
  if (this->svc_queue_ != 0)
    {
      ACE_TString *sptr = 0;
      for (ACE_SVC_QUEUE_ITERATOR iter (*this->svc_queue_);
           iter.next (sptr) != 0;
           iter.advance ())
        {
          // Process just a single directive.
          if (this->process_directive ((sptr->fast_rep ())) != 0)
            {
              ACELIB_ERROR ((LM_ERROR,
                          ACE_TEXT ("ACE (%P|%t) %p\n"),
                          ACE_TEXT ("process_directive")));
              result = -1;
            }
        }

      delete this->svc_queue_;
      this->svc_queue_ = 0;
    }

  return result;

} /* process_commandline_directives () */
Exemplo n.º 2
0
// Process service configuration directives from the files queued for
// processing
int
ACE_Service_Gestalt::process_directives (bool )
{
  ACE_TRACE ("ACE_Service_Gestalt::process_directives");
  if (this->svc_conf_file_queue_ == 0
       || this->svc_conf_file_queue_->is_empty ())
    {
      return 0;
    }

  ACE_TString *sptr = 0;
  int failed = 0;

  // Iterate through all the svc.conf files.
  for (ACE_SVC_QUEUE_ITERATOR iter (*this->svc_conf_file_queue_);
       iter.next (sptr) != 0;
       iter.advance ())
    {
      int result = this->process_file (sptr->fast_rep ());
      if (result < 0)
        return result;
      failed += result;
    }

  return failed;

} /* process_directives () */
Exemplo n.º 3
0
// Process service configuration directives from the files queued for
// processing
int
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;

  ACE_TString *sptr = 0;
  ACE_TString default_svc_conf (ACE_DEFAULT_SVC_CONF);

  // Iterate through all the svc.conf files.
  for (ACE_SVC_QUEUE_ITERATOR iter (*this->svc_conf_file_queue_);
       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;
    }

  return 0;

} /* process_directives () */
Exemplo n.º 4
0
int
ACE_Service_Gestalt::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)
{
  ACE_TRACE ("ACE_Service_Gestalt::open_i");
  int result = 0;
  ACE_Log_Msg *log_msg = ACE_LOG_MSG;

  this->no_static_svcs_ = ignore_static_svcs;

  // Record the current log setting upon entering this thread.
  u_long old_process_mask = log_msg->priority_mask
    (ACE_Log_Msg::PROCESS);

  u_long old_thread_mask = log_msg->priority_mask
    (ACE_Log_Msg::THREAD);

#ifndef ACE_NLOGGING
  if (ACE::debug ())
    ACELIB_DEBUG ((LM_DEBUG,
                ACE_TEXT ("ACE (%P|%t) SG::open_i - this=%@, ")
                ACE_TEXT ("opened=%d, loadstatics=%d\n"),
                this, this->is_opened_, this->no_static_svcs_));
#endif

  // Guard against reentrant processing. For example,
  // if the singleton gestalt (ubergestalt) was already open,
  // do not open it again...
  if (this->is_opened_++ != 0)
    return 0;

  if (this->init_i () != 0)
    return -1;

  u_long flags = log_msg->flags ();

  // Only use STDERR if the caller hasn't already set the flags.
  if (flags == 0)
    flags = (u_long) ACE_Log_Msg::STDERR;

  const ACE_TCHAR *key = logger_key;

  if (key == 0 || ACE_OS::strcmp (key, ACE_DEFAULT_LOGGER_KEY) == 0)
    {
      // Only use the static <logger_key_> if the caller doesn't
      // override it in the parameter list or if the key supplied is
      // equal to the default static logger key.
      key = this->logger_key_;
    }
  else
    {
      ACE_SET_BITS (flags, ACE_Log_Msg::LOGGER);
    }

  if (log_msg->open (program_name,
                     flags,
                     key) == -1)
    return -1;

  if (!ignore_debug_flag)
    {
      // If -d was included as a startup parameter, the user wants debug
      // information printed during service initialization.
      if (ACE::debug ())
        ACE_Log_Msg::enable_debug_messages ();
      else
        // The user has requested no debugging info.
        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;
          ACELIB_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)
        {
          int temp = this->process_commandline_directives ();
          if (temp == -1)
            result = -1;
          else result += temp;
        }
    }

  // Reset debugging back to the way it was when we came into
  // into <open_i>.
  {
    // Make sure to save/restore errno properly.
    ACE_Errno_Guard error (errno);

    if (!ignore_debug_flag)
      {
        log_msg->priority_mask (old_process_mask, ACE_Log_Msg::PROCESS);
        log_msg->priority_mask (old_thread_mask, ACE_Log_Msg::THREAD);
      }
  }

  return result;
} /* open_i () */