diff options
Diffstat (limited to 'TAO/CIAO/DAnCE/ExecutionManager/Execution_Manager.cpp')
-rw-r--r-- | TAO/CIAO/DAnCE/ExecutionManager/Execution_Manager.cpp | 66 |
1 files changed, 48 insertions, 18 deletions
diff --git a/TAO/CIAO/DAnCE/ExecutionManager/Execution_Manager.cpp b/TAO/CIAO/DAnCE/ExecutionManager/Execution_Manager.cpp index 2c62f431071..cfb3b55fc70 100644 --- a/TAO/CIAO/DAnCE/ExecutionManager/Execution_Manager.cpp +++ b/TAO/CIAO/DAnCE/ExecutionManager/Execution_Manager.cpp @@ -18,25 +18,30 @@ namespace CIAO { const char *ior_file_name_ = "executionManager.ior"; const char *init_file_name = "deployment.dat"; - - bool register_with_ns_ = 0; + const char *pid_file_name_ = 0; + static bool register_with_ns_ = false; + static bool write_to_ior_ = false; bool parse_args (int argc, char *argv[]) { - ACE_Get_Opt get_opts (argc, argv, "o:m:i:n"); + ACE_Get_Opt get_opts (argc, argv, "o:m:i:n:p"); int c; while ((c = get_opts ()) != -1) switch (c) { case 'o': + write_to_ior_ = true; ior_file_name_ = get_opts.opt_arg (); break; case 'i': init_file_name = get_opts.opt_arg (); break; case 'n': - register_with_ns_ = 1; + register_with_ns_ = true; + break; + case 'p': + pid_file_name_ = get_opts.opt_arg (); break; case '?': // display help for use of the server. default: @@ -79,6 +84,23 @@ namespace CIAO return true; } + void + write_pid (void) + { + if (pid_file_name_ == 0) + return; + + FILE* pid_file = ACE_OS::fopen (pid_file_name_, "w"); + + if (pid_file) + { + ACE_OS::fprintf (pid_file, + "%i", + ACE_OS::getpid ()); + ACE_OS::fclose (pid_file); + } + } + bool register_with_ns (CORBA::ORB_ptr orb, CIAO::ExecutionManagerDaemon_ptr obj @@ -94,18 +116,23 @@ namespace CIAO CosNaming::NamingContext::_narrow (naming_context_object.in ()); // Initialize the Naming Sequence - CosNaming::Name name (2); - name.length (2); + CosNaming::Name name (1); + name.length (1); // String dup required for MSVC6 - name[0].id = CORBA::string_dup ("CIAO"); - name[1].id = CORBA::string_dup ("ExecutionManager"); + name[0].id = CORBA::string_dup ("ExecutionManager"); // Register the servant with the Naming Service - naming_context->bind (name, - obj - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (false); + try + { + // Register the servant with the Naming Service + naming_context->bind (name, obj); + } + catch (CosNaming::NamingContext::AlreadyBound &) + { + ACE_DEBUG ((LM_DEBUG, "Execution_Manager.cpp: Name already bound, rebinding....\n")); + naming_context->rebind (name, obj); + } return true; } @@ -141,9 +168,9 @@ namespace CIAO if (poa.in () == 0) ACE_ERROR_RETURN ((LM_ERROR, - "(%P|%t) CIAO_ExecutionManager: " + "(%P|%t) CIAO_ExecutionManager: " "Nil POA panic error, returning \n"), - -1); + -1); // Create and install the CIAO Daemon servant Execution_Manager_Impl *daemon_servant = 0; @@ -160,7 +187,7 @@ namespace CIAO daemon_servant->_this (); TAO::Utils::Implicit_Deactivator de (daemon_servant); - + ACE_TRY_CHECK; bool retval = false; @@ -173,7 +200,8 @@ namespace CIAO ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; } - else + + if (write_to_ior_) { retval = write_ior_file (orb.in (), @@ -194,7 +222,7 @@ namespace CIAO ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) CIAO_ExecutionManager: " "Nil POA Manager error, returning \n"), - -1); + -1); mgr->activate (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; @@ -203,6 +231,8 @@ namespace CIAO ACE_DEBUG ((LM_DEBUG, "CIAO_ExecutionManager is running...\n")); + write_pid (); + // Run the main event loop for the ORB. orb->run (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; @@ -239,5 +269,5 @@ int main (int argc, char *argv[]) { return CIAO::Execution_Manager::run_main (argc, - argv); + argv); } |