From 74384fdeac57b7eb1856ca9d0f4dd45057326c3c Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Sat, 26 Oct 2024 00:53:47 +0900 Subject: [PATCH] Shutdown `mozc_{server,renderer}.exe` on upgrading (#1093) It would make more sense to shutdown mozc_server/mozc_renderer not only when uninstalling Mozc but also when upgrading Mozc. With this commit * 'ShutdownServer' custom actions will always run * Any failure on 'ShutdownServer' will not block installation/upgrading as it is an optional behavior and Windows Installer can proceed even when these processes continue running. Closes #1092. PiperOrigin-RevId: 689660268 --- src/win32/custom_action/custom_action.cc | 18 ++++++++---------- src/win32/installer/installer_64bit.wxs | 2 +- src/win32/installer/installer_oss_64bit.wxs | 2 +- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/win32/custom_action/custom_action.cc b/src/win32/custom_action/custom_action.cc index 55e311226..f0f5f6520 100644 --- a/src/win32/custom_action/custom_action.cc +++ b/src/win32/custom_action/custom_action.cc @@ -244,21 +244,19 @@ UINT __stdcall ShutdownServer(MSIHANDLE msi_handle) { DEBUG_BREAK_FOR_DEBUGGER(); std::unique_ptr server_client( mozc::client::ClientFactory::NewClient()); - bool server_result = true; if (server_client->PingServer()) { - server_result = server_client->Shutdown(); + if (!server_client->Shutdown()) { + // This is not fatal as Windows Installer can replace executables even + // when they still are running. Just log error then go ahead. + LOG_ERROR_FOR_OMAHA(); + } } mozc::renderer::RendererClient renderer_client; - const bool renderer_result = renderer_client.Shutdown(true); - if (!server_result) { + if (!renderer_client.Shutdown(true)) { + // This is not fatal as Windows Installer can replace executables even when + // they are still running. Just log error then go ahead. LOG_ERROR_FOR_OMAHA(); - return ERROR_INSTALL_FAILURE; } - if (!renderer_result) { - LOG_ERROR_FOR_OMAHA(); - return ERROR_INSTALL_FAILURE; - } - return ERROR_SUCCESS; } diff --git a/src/win32/installer/installer_64bit.wxs b/src/win32/installer/installer_64bit.wxs index 9a24fcbd1..ec0f6552e 100644 --- a/src/win32/installer/installer_64bit.wxs +++ b/src/win32/installer/installer_64bit.wxs @@ -174,7 +174,7 @@ are currenly running. So the ShutdownServer action needs to be callled before the InstallValidate action. --> - + - +