Exemple #1
0
int
DllORB::init (int argc, ACE_TCHAR *argv[])
{
  int threadCnt = 1;

  try
    {
      ACE_Arg_Shifter as (argc, argv);
      const ACE_TCHAR *currentArg = 0;
      while (as.is_anything_left ())
        {
          if ((currentArg = as.get_the_parameter (ACE_TEXT ("-NumThreads"))))
            {
              int num = ACE_OS::atoi (currentArg);
              if (num >= 1)
                threadCnt = num;
              as.consume_arg ();
            }
        else
          as.ignore_arg ();
        }

      if (failPrePostInit_ < 3)
        {
          ACE_DEBUG ((LM_INFO,
                      ACE_TEXT ("Pre-ORB initialization ...\n")));
          // -----------------------------------------------------------------
          // Pre-ORB initialization steps necessary for proper DLL ORB
          // support.
          // -----------------------------------------------------------------
          // Make sure TAO's singleton manager is initialized, and set to not
          // register itself with the ACE_Object_Manager since it is under the
          // control of the Service Configurator.  If we register with the
          // ACE_Object_Manager, then the ACE_Object_Manager will still hold
          // (dangling) references to instances of objects created by this
          // module and destroyed by this object when it is dynamically
          // unloaded.
          int register_with_object_manager = 0;
          TAO_Singleton_Manager * p_tsm = TAO_Singleton_Manager::instance ();
          int result = p_tsm->init (register_with_object_manager);

          if (result == -1)
            {
              if (failPrePostInit_ == 0)
                {
                  ACE_DEBUG ((LM_ERROR,
                              ACE_TEXT ("Pre-ORB initialization failed.\n")));
                  return -1;
                }
              else if (failPrePostInit_ < 2)
                {
                  ACE_DEBUG ((LM_WARNING,
                              ACE_TEXT ("Pre-ORB initialization failed (ignored due to FailPrePostInit setting).\n")));
                }
              else
                {
                  ACE_DEBUG ((LM_INFO,
                              ACE_TEXT ("Pre-ORB initialization failed (ignored due to FailPrePostInit setting).\n")));
                }
            }
          else
            {
              ACE_DEBUG ((LM_INFO,
                          ACE_TEXT ("Pre-ORB initialization done.\n")));
            }
        }

      // Initialize the ORB
      ACE_Argv_Type_Converter argcon (argc, argv);
      mv_orb_ = CORBA::ORB_init (argcon.get_argc (), argcon.get_TCHAR_argv ());
      if (CORBA::is_nil (mv_orb_.in ()))
        {
          ACE_DEBUG ((LM_ERROR, ACE_TEXT ("nil ORB\n")));
          return -1;
        }

      CORBA::Object_var v_poa =
        mv_orb_->resolve_initial_references ("RootPOA");

      mv_rootPOA_ = PortableServer::POA::_narrow (v_poa.in ());
      if (CORBA::is_nil (mv_rootPOA_.in ()))
        {
          ACE_DEBUG ((LM_ERROR, ACE_TEXT ("nil RootPOA\n")));
          return -1;
        }

      mv_poaManager_ = mv_rootPOA_->the_POAManager ();
      if (CORBA::is_nil (mv_poaManager_.in ()))
        {
          ACE_DEBUG ((LM_ERROR, ACE_TEXT ("nil POAManager\n")));
          return -1;
        }

      mv_poaManager_->activate ();
    }
  catch (...)
  {
    ACE_DEBUG ((LM_ERROR, ACE_TEXT ("ERROR: exception\n")));
    return -1;
  }

  mp_barrier_ = new ACE_Thread_Barrier (threadCnt + 1);

  this->activate (THR_NEW_LWP|THR_JOINABLE|THR_INHERIT_SCHED, threadCnt);
  mp_barrier_->wait ();

  return 0;
}
Exemple #2
0
int DllOrb::init (int argc, ACE_TCHAR *argv[])
{
  int result = 0;
  int threadCnt = this->m_nthreads_;

  try
  {
    ACE_Arg_Shifter as (argc, argv);
    const ACE_TCHAR *currentArg = 0;
    while (as.is_anything_left ())
      {
        if (0 != (currentArg = as.get_the_parameter (ACE_TEXT ("-t"))))
          {
            int num = ACE_OS::atoi (currentArg);
            if (num >= 1)
              threadCnt = num;
            as.consume_arg ();
          }
        else
          as.ignore_arg ();
      }

    if (m_failPrePostInit < 3)
      {
        ACE_DEBUG((LM_DEBUG, "TEST (%P|%t) Pre-ORB initialization ...\n"));

        // -----------------------------------------------------------------
        // Pre-ORB initialization steps necessary for proper DLL ORB
        // support.
        // -----------------------------------------------------------------
        // Make sure TAO's singleton manager is initialized, and set to not
        // register itself with the ACE_Object_Manager since it is under the
        // control of the Service Configurator.  If we register with the
        // ACE_Object_Manager, then the ACE_Object_Manager will still hold
        // (dangling) references to instances of objects created by this
        // module and destroyed by this object when it is dynamically
        // unloaded.
        int register_with_object_manager = 0;
        TAO_Singleton_Manager * p_tsm = TAO_Singleton_Manager::instance ();
        result = p_tsm->init (register_with_object_manager);

        if (result == -1 && m_failPrePostInit == 0)
          return -1;
      }

    // Initialize the ORB
    mv_orb = CORBA::ORB_init (argc, argv);
    if (CORBA::is_nil (mv_orb.in ()))
      return -1;

    CORBA::Object_var v_poa = mv_orb->resolve_initial_references ("RootPOA");

    mv_rootPOA = PortableServer::POA::_narrow (v_poa.in ());
    if (CORBA::is_nil (mv_rootPOA.in ()))
      return -1;

    mv_poaManager = mv_rootPOA->the_POAManager ();
    if (CORBA::is_nil (mv_poaManager.in ()))
      return -1;

    mv_poaManager->activate ();
  }
  catch(CORBA::Exception& ex)
  {
    ex._tao_print_exception (ACE_TEXT ("(%P|%t) init failed:"));
    return -1;
  }
  catch (...)
  {
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("(%P|%t) init failed\n")),
                      -1);
  }

#if defined (ACE_HAS_THREADS)
  mp_barrier = new ACE_Thread_Barrier (threadCnt + 1);

  this->activate(
                 THR_NEW_LWP|THR_JOINABLE|THR_INHERIT_SCHED,
                 threadCnt
                 );
  mp_barrier->wait ();
#endif

  return 0;
}
Exemple #3
0
int
DllOrb::init (int argc, ACE_TCHAR *argv[])
{
  int threadCnt = 1;

  try
  {
    ACE_Arg_Shifter as (argc, argv);
    const ACE_TCHAR *currentArg = 0;
    while (as.is_anything_left ())
    {
      if (0 != (currentArg = as.get_the_parameter (ACE_TEXT ("-NumThreads"))))
      {
        int num = ACE_OS::atoi (currentArg);
        if (num >= 1)
          threadCnt = num;
        as.consume_arg ();
      }
      else
        as.ignore_arg ();
    }

    // Initialize the ORB
    mv_orb_ = CORBA::ORB_init (argc, argv);
    if (CORBA::is_nil (mv_orb_.in ()))
    {
      ACE_DEBUG ((LM_ERROR, ACE_TEXT ("nil ORB\n")));
      return -1;
    }

    CORBA::Object_var v_poa =
      mv_orb_->resolve_initial_references ("RootPOA");

    mv_rootPOA_ = PortableServer::POA::_narrow (v_poa.in ());
    if (CORBA::is_nil (mv_rootPOA_.in ()))
    {
      ACE_DEBUG ((LM_ERROR, ACE_TEXT ("nil RootPOA\n")));
      return -1;
    }

    mv_poaManager_ = mv_rootPOA_->the_POAManager ();
    if (CORBA::is_nil (mv_poaManager_.in ()))
    {
      ACE_DEBUG ((LM_ERROR, ACE_TEXT ("nil POAManager\n")));
      return -1;
    }

    mv_poaManager_->activate ();
  }
  catch (...)
  {
    ACE_DEBUG ((LM_ERROR, ACE_TEXT ("ERROR: exception\n")));
    return -1;
  }

  ACE_auto_ptr_reset (ma_barrier_, new ACE_Thread_Barrier (threadCnt + 1));

  this->activate(
    THR_NEW_LWP|THR_JOINABLE|THR_INHERIT_SCHED,
    threadCnt
  );
  ACE_DEBUG ((LM_INFO, ACE_TEXT ("init mp_barrier->wait() ...\n")));
  ma_barrier_->wait();
  ACE_DEBUG ((LM_INFO, ACE_TEXT ("init mp_barrier->wait() done\n")));

  return 0;
}
Exemple #4
0
int
Activator_Options::parse_args (int &argc, ACE_TCHAR *argv[])
{
    ACE_Arg_Shifter shifter (argc, argv);

    while (shifter.is_anything_left ())
    {
        if (ACE_OS::strcasecmp (shifter.get_current (),
                                ACE_TEXT ("-c")) == 0)
        {
            shifter.consume_arg ();

            if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
            {
                ORBSVCS_ERROR ((LM_ERROR, "Error: -c option needs a command\n"));
                this->print_usage ();
                return -1;
            }

            if (ACE_OS::strcasecmp (shifter.get_current (),
                                    ACE_TEXT ("install")) == 0)
            {
                this->service_command_ = SC_INSTALL;
            }
            else if (ACE_OS::strcasecmp (shifter.get_current (),
                                         ACE_TEXT ("remove")) == 0)
            {
                this->service_command_ = SC_REMOVE;
            }
            else if (ACE_OS::strcasecmp (shifter.get_current (),
                                         ACE_TEXT ("install_no_imr")) == 0)
            {
                this->service_command_ = SC_INSTALL_NO_LOCATOR;
            }
            else
            {
                ORBSVCS_ERROR((LM_ERROR, "Error: Unknown service command : %s\n", shifter.get_current()));
                this->print_usage ();
                return -1;
            }
        }
        else if (ACE_OS::strcasecmp (shifter.get_current (),
                                     ACE_TEXT ("-d")) == 0)
        {
            shifter.consume_arg ();

            if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
            {
                ORBSVCS_ERROR ((LM_ERROR, "Error: -d option needs a debuglevel\n"));
                this->print_usage ();
                return -1;
            }

            this->debug_ = ACE_OS::atoi (shifter.get_current ());
        }
        else if (ACE_OS::strcasecmp (shifter.get_current (),
                                     ACE_TEXT ("-e")) == 0)
        {
            shifter.consume_arg ();

            if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
            {
                ORBSVCS_ERROR ((LM_ERROR, "Error: -e option needs "
                                "an environment buffer length\n"));
                this->print_usage ();
                return -1;
            }

            this->env_buf_len_ = ACE_OS::atoi (shifter.get_current ());
        }
        else if (ACE_OS::strcasecmp (shifter.get_current (),
                                     ACE_TEXT ("-m")) == 0)
        {
            shifter.consume_arg ();

            if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
            {
                ORBSVCS_ERROR ((LM_ERROR, "Error: -m option needs "
                                "a maximum number of environment vars\n"));
                this->print_usage ();
                return -1;
            }

            this->max_env_vars_ = ACE_OS::atoi (shifter.get_current ());
        }
        else if (ACE_OS::strcasecmp (shifter.get_current (),
                                     ACE_TEXT ("-o")) == 0)
        {
            shifter.consume_arg ();

            if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
            {
                ORBSVCS_ERROR ((LM_ERROR, "Error: -o option needs a filename\n"));
                this->print_usage ();
                return -1;
            }
            this->ior_output_file_ = shifter.get_current ();
        }
        else if (ACE_OS::strcasecmp (shifter.get_current (),
                                     ACE_TEXT ("-s")) == 0)
        {
            this->service_ = true;
        }
        else if ((ACE_OS::strcasecmp (shifter.get_current (),
                                      ACE_TEXT ("-?")) == 0)
                 || (ACE_OS::strcasecmp (shifter.get_current (),
                                         ACE_TEXT ("-h")) == 0))
        {
            this->print_usage ();
            return 1;
        }
        else if (ACE_OS::strcasecmp (shifter.get_current (),
                                     ACE_TEXT ("-n")) == 0)
        {
            shifter.consume_arg ();

            if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
            {
                ORBSVCS_ERROR ((LM_ERROR, "Error: -n option needs a name\n"));
                this->print_usage ();
                return -1;
            }
            this->name_ = ACE_TEXT_ALWAYS_CHAR(shifter.get_current ());
        }
        else if (ACE_OS::strcasecmp (shifter.get_current (),
                                     ACE_TEXT ("-l")) == 0)
        {
            this->notify_imr_ = true;
        }
        else if (ACE_OS::strcasecmp (shifter.get_current (),
                                     ACE_TEXT ("-delay")) == 0)
        {
            shifter.consume_arg ();

            if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
            {
                ORBSVCS_ERROR ((LM_ERROR, "Error: -delay option needs a value\n"));
                this->print_usage ();
                return -1;
            }
            this->induce_delay_ = ACE_OS::atoi (shifter.get_current ());
        }
        else if (ACE_OS::strcasecmp (shifter.get_current (),
                                     ACE_TEXT ("-detach")) == 0)
        {
            shifter.consume_arg ();

            if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
            {
                ORBSVCS_ERROR ((LM_ERROR, "Error: -detach option needs a value\n"));
                this->print_usage ();
                return -1;
            }
            this->detach_child_ = ACE_OS::atoi (shifter.get_current ()) != 0;
        }

        else
        {
            shifter.ignore_arg ();
            continue;
        }

        shifter.consume_arg ();
    }
    return 0;
}