Skip to content

Commit aa3db8b

Browse files
authored
Merge pull request #1280 from dorssel/fix_installer_timing
Add installer delay for detach/unbind to complete
2 parents dd0920c + 8abe41d commit aa3db8b

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

Installer/Server.wxs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ SPDX-License-Identifier: GPL-3.0-only
111111
<SetProperty Id="DetachAll" Value="&quot;[#usbipd.exe]&quot; detach --all" Sequence="execute" Before="DetachAll" Condition="$(var.UpdateOrRepair)" />
112112
<CustomAction Id="DetachAll" BinaryRef="Wix4UtilCA_$(sys.BUILDARCHSHORT)" DllEntry="WixQuietExec" Return="ignore" Impersonate="no" Execute="deferred" />
113113

114+
<!-- Delay so detach can finish its side effects. -->
115+
<!-- NOTE: This will run the *old* (to be upgraded or repaired) version. -->
116+
<SetProperty Id="DelayAfterDetach" Value="&quot;[#usbipd.exe]&quot; installer delay" Sequence="execute" Before="DelayAfterDetach" Condition="$(var.UpdateOrRepair)" />
117+
<CustomAction Id="DelayAfterDetach" BinaryRef="Wix4UtilCA_$(sys.BUILDARCHSHORT)" DllEntry="WixQuietExec" Return="ignore" Impersonate="no" Execute="deferred" />
118+
114119
<!-- Disable all force-bound devices, such that (after DetachAll) the VBoxUSB driver is not used at all (best effort). -->
115120
<!-- NOTE: This will run the *old* (to be upgraded or repaired) version (< 5.3.0 does not even have this). -->
116121
<SetProperty Id="DisableForced" Value="&quot;[#usbipd.exe]&quot; installer disable_forced" Sequence="execute" Before="DisableForced" Condition="$(var.UpdateOrRepair)" />
@@ -120,6 +125,10 @@ SPDX-License-Identifier: GPL-3.0-only
120125
<SetProperty Id="UnbindAll" Value="&quot;[#usbipd.exe]&quot; unbind --all" Sequence="execute" Before="UnbindAll" Condition="$(var.UninstallOnly)" />
121126
<CustomAction Id="UnbindAll" BinaryRef="Wix4UtilCA_$(sys.BUILDARCHSHORT)" DllEntry="WixQuietExec" Return="ignore" Impersonate="no" Execute="deferred" />
122127

128+
<!-- Delay so unbind can finish its side effects. -->
129+
<SetProperty Id="DelayAfterUnbind" Value="&quot;[#usbipd.exe]&quot; installer delay" Sequence="execute" Before="DelayAfterUnbind" Condition="$(var.UninstallOnly)" />
130+
<CustomAction Id="DelayAfterUnbind" BinaryRef="Wix4UtilCA_$(sys.BUILDARCHSHORT)" DllEntry="WixQuietExec" Return="ignore" Impersonate="no" Execute="deferred" />
131+
123132
<!-- This will uninstall all stub devices, so they don't "use" the VBoxUSB driver (remember: they are already inactive at this point) (cleanup) (best effort). -->
124133
<SetProperty Id="UninstallStubs1" Value="&quot;[#usbipd.exe]&quot; installer uninstall_stubs" Sequence="execute" Before="UninstallStubs1" Condition="$(var.UninstallOnly)" />
125134
<CustomAction Id="UninstallStubs1" BinaryRef="Wix4UtilCA_$(sys.BUILDARCHSHORT)" DllEntry="WixQuietExec" Return="ignore" Impersonate="no" Execute="deferred" />
@@ -166,8 +175,10 @@ SPDX-License-Identifier: GPL-3.0-only
166175

167176
<InstallExecuteSequence>
168177
<Custom Action="DetachAll" Before="StopServices" Condition="$(var.UpdateOrRepair)" />
178+
<Custom Action="DelayAfterDetach" Before="StopServices" Condition="$(var.UpdateOrRepair)" />
169179
<Custom Action="DisableForced" Before="StopServices" Condition="$(var.UpdateOrRepair)" />
170180
<Custom Action="UnbindAll" Before="StopServices" Condition="$(var.UninstallOnly)" />
181+
<Custom Action="DelayAfterUnbind" Before="StopServices" Condition="$(var.UninstallOnly)" />
171182
<Custom Action="UninstallStubs1" Before="StopServices" Condition="$(var.UninstallOnly)" />
172183
<Custom Action="UninstallOldDrivers1" Before="StopServices" Condition="$(var.UninstallOnly)" />
173184
<Custom Action="UninstallDriver" Before="StopServices" Condition="$(var.UninstallOnly)" />

Usbipd/CommandHandlersInstaller.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ namespace Usbipd;
1414

1515
sealed partial class CommandHandlers : ICommandHandlers
1616
{
17+
async Task<ExitCode> ICommandHandlers.InstallerDelay(IConsole console, CancellationToken cancellationToken)
18+
{
19+
ConsoleTools.ReportInfo(console, $"delay");
20+
21+
await Task.Delay(TimeSpan.FromSeconds(2), cancellationToken);
22+
23+
return ExitCode.Success;
24+
}
25+
1726
Task<ExitCode> ICommandHandlers.InstallerInstallDriver(IConsole console, CancellationToken cancellationToken)
1827
{
1928
ConsoleTools.ReportInfo(console, "install_driver");

Usbipd/ICommandHandlers.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Task<ExitCode> AttachWsl(VidPid vidPid, bool autoAttach, string? distribution, I
3535
Task<ExitCode> Server(string[] args, IConsole console, CancellationToken cancellationToken);
3636

3737
// Installer
38+
Task<ExitCode> InstallerDelay(IConsole console, CancellationToken cancellationToken);
3839
Task<ExitCode> InstallerInstallDriver(IConsole console, CancellationToken cancellationToken);
3940
Task<ExitCode> InstallerUpdateDrivers(IConsole console, CancellationToken cancellationToken);
4041
Task<ExitCode> InstallerInstallMonitor(IConsole console, CancellationToken cancellationToken);

Usbipd/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,7 @@ await action(console, cancellationToken)
748748
installCommand.Subcommands.Add(subcommand);
749749
}
750750

751+
AddInstallerSubcommand("delay", commandHandlers.InstallerDelay);
751752
AddInstallerSubcommand("install_driver", commandHandlers.InstallerInstallDriver);
752753
AddInstallerSubcommand("uninstall_driver", commandHandlers.InstallerUninstallDriver);
753754
AddInstallerSubcommand("update_drivers", commandHandlers.InstallerUpdateDrivers);

0 commit comments

Comments
 (0)