Skip to content

Commit

Permalink
Shutdown mozc_{server,renderer}.exe on upgrading (#1093)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
yukawa authored Oct 25, 2024
1 parent df9931d commit 74384fd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
18 changes: 8 additions & 10 deletions src/win32/custom_action/custom_action.cc
Original file line number Diff line number Diff line change
Expand Up @@ -244,21 +244,19 @@ UINT __stdcall ShutdownServer(MSIHANDLE msi_handle) {
DEBUG_BREAK_FOR_DEBUGGER();
std::unique_ptr<mozc::client::ClientInterface> 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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/win32/installer/installer_64bit.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
are currenly running. So the ShutdownServer action
needs to be callled before the InstallValidate action.
-->
<Custom Action="ShutdownServer" Before="InstallValidate" Condition="(REMOVE=&quot;ALL&quot;) AND (NOT UPGRADINGPRODUCTCODE)" />
<Custom Action="ShutdownServer" Before="InstallValidate" />
<Custom Action="NewerVersionError" After="FindRelatedProducts" Condition="NEWERVERSIONDETECTED" />
<!--
RemoveExistingProducts needs to be scheduled between InstallExecute and
Expand Down
2 changes: 1 addition & 1 deletion src/win32/installer/installer_oss_64bit.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
are currenly running. So the ShutdownServer action
needs to be callled before the InstallValidate action.
-->
<Custom Action="ShutdownServer" Before="InstallValidate" Condition="(REMOVE=&quot;ALL&quot;) AND (NOT UPGRADINGPRODUCTCODE)" />
<Custom Action="ShutdownServer" Before="InstallValidate" />
<Custom Action="NewerVersionError" After="FindRelatedProducts" Condition="NEWERVERSIONDETECTED" />
<!--
RemoveExistingProducts needs to be scheduled between InstallExecute and
Expand Down

0 comments on commit 74384fd

Please sign in to comment.