winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 7fb08ffd9f867631c5bde45635092e924494723e
parent 2a9d1c66a32af0f44f6dd9b6ad76e88d427efc11
Author: sreadingMSFT <74242768+sreadingMSFT@users.noreply.github.com>
Date:   Thu, 16 Sep 2021 02:10:50 -0700

Remove cancel optimization for packageQuery caller (#1472)


Diffstat:
Msrc/Microsoft.Management.Deployment/PackageManager.cpp | 18+++---------------
1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/src/Microsoft.Management.Deployment/PackageManager.cpp b/src/Microsoft.Management.Deployment/PackageManager.cpp @@ -427,7 +427,6 @@ namespace winrt::Microsoft::Management::Deployment::implementation } wil::unique_event progressEvent{ wil::EventOptions::None }; - wil::unique_event cancelWaitEvent{ wil::EventOptions::None }; std::atomic<winrt::Microsoft::Management::Deployment::InstallProgress> installProgress; queueItem->GetContext().AddProgressCallbackFunction([&installProgress, &progressEvent]( @@ -448,7 +447,7 @@ namespace winrt::Microsoft::Management::Deployment::implementation ); std::weak_ptr<Execution::OrchestratorQueueItem> weakQueueItem(queueItem); - cancellationToken.callback([weakQueueItem, &canCancelQueueItem, &cancelWaitEvent] + cancellationToken.callback([weakQueueItem, &canCancelQueueItem] { if (canCancelQueueItem) { @@ -458,21 +457,15 @@ namespace winrt::Microsoft::Management::Deployment::implementation Execution::ContextOrchestrator::Instance().CancelQueueItem(*strongQueueItem); } } - else - { - cancelWaitEvent.SetEvent(); - } }); // Wait for completion or progress events. // Waiting for both on the same thread ensures that progress is never reported after the async operation itself has completed. bool completionEventFired = false; - bool cancelWaitEventFired = false; - HANDLE operationEvents[3]; + HANDLE operationEvents[2]; operationEvents[0] = progressEvent.get(); operationEvents[1] = queueItem->GetCompletedEvent().get(); - operationEvents[2] = cancelWaitEvent.get(); - while (!completionEventFired && !cancelWaitEventFired) + while (!completionEventFired) { DWORD dwEvent = WaitForMultipleObjects( _countof(operationEvents) /* number of events */, @@ -497,11 +490,6 @@ namespace winrt::Microsoft::Management::Deployment::implementation completionEventFired = true; break; - // operationEvents[2] was signaled, operation is cancelled - case WAIT_OBJECT_0 + 2: - cancelWaitEventFired = true; - break; - // Return value is invalid. default: THROW_LAST_ERROR();