示例#1
0
/// Performs the common initialization tasks for a new or previously
/// closed instance. Must not be virtual, as it is also called from
/// the constructor.
int
ACE_Service_Gestalt::init_i (void)
{
  // Only initialize the repo_ if (a) we are being constructed, or;
  // (b) we're being open()-ed, perhaps after previously having been
  // close()-ed. In both cases: repo_ == 0 and we need a repository.
  if (this->repo_ == 0)
    {
      if (this->svc_repo_is_owned_)
        {
          ACE_NEW_RETURN (this->repo_,
                          ACE_Service_Repository (this->svc_repo_size_),
                          -1);
        }
      else
        {
          this->repo_ =
            ACE_Service_Repository::instance (this->svc_repo_size_);
        }
    }

  if (init_svc_conf_file_queue () == -1)
    return -1;

  return 0;
}
示例#2
0
/// Performs the common initialization tasks for a new or previously
/// closed instance. Must not be virtual, as it is also called from
/// the constructor.
int
ACE_Service_Gestalt::init_i (void)
{
  // Only initialize the repo_ if (a) we are being constructed, or;
  // (b) we're being open()-ed, perhaps after previously having been
  // close()-ed. In both cases: repo_ == 0 and we need a repository.
  if (this->repo_ == 0)
    {
      if (this->svc_repo_is_owned_)
        {
          ACE_NEW_RETURN (this->repo_,
                          ACE_Service_Repository (this->svc_repo_size_),
                          -1);
        }
      else
        {
          this->repo_ =
            ACE_Service_Repository::instance (this->svc_repo_size_);
        }
    }

  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;
}