diff options
Diffstat (limited to 'TAO/orbsvcs/ImplRepo_Service/ImR_Activator.cpp')
-rw-r--r-- | TAO/orbsvcs/ImplRepo_Service/ImR_Activator.cpp | 92 |
1 files changed, 47 insertions, 45 deletions
diff --git a/TAO/orbsvcs/ImplRepo_Service/ImR_Activator.cpp b/TAO/orbsvcs/ImplRepo_Service/ImR_Activator.cpp index ecaf693dde9..e40c8e6028a 100644 --- a/TAO/orbsvcs/ImplRepo_Service/ImR_Activator.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/ImR_Activator.cpp @@ -10,7 +10,7 @@ class ImR_Activator_Shutdown : public Shutdown_Functor { public: - ImR_Activator_Shutdown(ImR_Activator_i& act); + ImR_Activator_Shutdown (ImR_Activator_i& act); void operator() (int which_signal); private: @@ -28,7 +28,7 @@ ImR_Activator_Shutdown::operator() (int /*which_signal*/) ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY { - this->act_.shutdown(true ACE_ENV_ARG_PARAMETER); + this->act_.shutdown (true ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; } ACE_CATCHANY @@ -44,7 +44,7 @@ run_standalone (Activator_Options& opts) ImR_Activator_i server; ImR_Activator_Shutdown killer (server); - Service_Shutdown kill_contractor(killer); + Service_Shutdown kill_contractor (killer); ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY @@ -117,7 +117,7 @@ run_service (void) static int run_service_command (Activator_Options& opts) { - if (opts.service_command() == Activator_Options::SC_NONE) + if (opts.service_command () == Activator_Options::SC_NONE) return 0; #if defined (ACE_WIN32) @@ -129,44 +129,47 @@ run_service_command (Activator_Options& opts) const DWORD MAX_PATH_LENGTH = 4096; ACE_TCHAR pathname[MAX_PATH_LENGTH]; - DWORD length = ACE_TEXT_GetModuleFileName(NULL, pathname, MAX_PATH_LENGTH); - if (length == 0 || length >= MAX_PATH_LENGTH - sizeof(" -s")) + DWORD length = ACE_TEXT_GetModuleFileName(NULL, pathname, MAX_PATH_LENGTH); + if (length == 0 || length >= MAX_PATH_LENGTH - sizeof(" -s")) + { + ACE_ERROR ((LM_ERROR, "Error: Could not get module file name\n")); + return -1; + } + + // Append the command used for running the implrepo as a service + ACE_OS::strcat (pathname, ACE_TEXT (" -s")); + int ret = -1; + if (opts.service_command () == Activator_Options::SC_INSTALL) + { + const ACE_TCHAR* DEPENDS_ON = ACE_TEXT("TAOImR"); // Must match Locator_NT_Service.h + + ret = SERVICE::instance ()->insert (SERVICE_DEMAND_START, + SERVICE_ERROR_NORMAL, + pathname, + 0, // group + 0, // tag + DEPENDS_ON + ); + } + else + { + ret = SERVICE::instance ()->insert (SERVICE_DEMAND_START, + SERVICE_ERROR_NORMAL, + pathname); + } + if (ret != -1) { - ACE_ERROR ((LM_ERROR, "Error: Could not get module file name\n")); - return -1; + ACE_DEBUG ((LM_DEBUG, "ImR Activator: Service installed.\n")); + opts.save_registry_options (); } - - // Append the command used for running the implrepo as a service - ACE_OS::strcat (pathname, ACE_TEXT (" -s")); - int ret = -1; - if (opts.service_command() == Activator_Options::SC_INSTALL) - { - const ACE_TCHAR* DEPENDS_ON = ACE_TEXT("TAOImR"); // Must match Locator_NT_Service.h - - ret = SERVICE::instance ()->insert (SERVICE_DEMAND_START, - SERVICE_ERROR_NORMAL, - pathname, - 0, // group - 0, // tag - DEPENDS_ON - ); - } else - { - ret = SERVICE::instance ()->insert (SERVICE_DEMAND_START, - SERVICE_ERROR_NORMAL, - pathname); - } - if (ret != -1) { - ACE_DEBUG ((LM_DEBUG, "ImR Activator: Service installed.\n")); - opts.save_registry_options(); - } else { - ACE_ERROR((LM_ERROR, "Error: Failed to install service.\n")); - } + { + ACE_ERROR ((LM_ERROR, "Error: Failed to install service.\n")); + } if (ret == 0) return 1; } - else if (opts.service_command() == Activator_Options::SC_REMOVE) + else if (opts.service_command () == Activator_Options::SC_REMOVE) { int ret = SERVICE::instance ()->remove (); ACE_DEBUG ((LM_DEBUG, "ImR Activator: Service removed.\n")); @@ -174,11 +177,11 @@ run_service_command (Activator_Options& opts) return 1; // If successfull, then we don't want to continue. } else - { - ACE_ERROR ((LM_ERROR, "Error: Unknown service command :%d \n", - opts.service_command())); - return -1; - } + { + ACE_ERROR ((LM_ERROR, "Error: Unknown service command :%d \n", + opts.service_command ())); + return -1; + } return -1; @@ -199,15 +202,14 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[]) else if (result > 0) return 0; // No error, but we should exit anyway. - result = run_service_command(opts); + result = run_service_command (opts); if (result < 0) return 1; // Error else if (result > 0) return 0; // No error, but we should exit anyway. - if (opts.service()) - return run_service(); + if (opts.service ()) + return run_service (); return run_standalone (opts); } - |