Commit d0096b3
authored
Improve COM server quiescing (#5652)
## Issue
When the package needs to be updated, the COM server does not currently
shut down in response to the signals that it receives. This is because
it only shuts down when all COM object references have been released. We
need to be more proactive in termination as the process will be
terminated shortly after we are notified either way.
## Change
This change refactors the existing shutdown signaling code out from
`ExecutionContext.cpp` into its own, public location. It then adds
another system for coordinating complex shutdown that is triggered by
the signaler.
Individual subsystems can register with the shutdown synchronizer with
functions for:
- Disable new work
- Cancel current work
- Wait for quiesce
and on shutdown initialization, all subsystems are called for each stage
in order. When the final subsystem returns from waiting, the existing
"all COM objects have been released" event is signaled and the process
will exit.
Additionally, the shutdown signal handler waits for shutdown
synchronization to complete in the window message function as after we
return from that we are expected to be gone shortly after. While this
will lead to some increased number of non-quiescing processes, we want
to do the best that we can to cooperatively exit.
> [!NOTE]
> Any actions being taken by callers outside of those described below
will **NOT** block the process from exiting.
### Package Management
Registers with synchronization on `PackageManager` creation. All of its
functions lead back to the `ContextOrchestrator` which has been
enlightened to handle the shutdown (and to operate as a contained set of
instances for test purposes).
- **Disable new work** causes the orchestrator to refuse to queue items
with an exception for new items and a cancellation for existing ones.
- **Cancel current work** causes all queued items to be cancelled, with
different handling based on current status.
- **Wait for quiesce** waits on an event for each queue that is signaled
when the queue is empty.
### Configuration
Registers with synchronization on `ConfigurationStaticFunctionsShim`
creation (the `IConfigurationStatics` for OOP use). All of its functions
are routed through `IConfigurationStaticsInternals` to a new shutdown
handler. It tracks all of the async token objects used in the
"background" sections of the `ConfigurationProcessor` functions. This
tracking is performed automatically by new types that manage that
tracking with the lifetime. It also enables non-async invocations to be
cancelled by providing a dummy promise into the existing system.
- **Disable new work** causes an error whenever a new async token object
is created.
- **Cancel current work** causes all tracked async tokens to have their
`Cancel` function invoked.
- **Wait for quiesce** waits until all async tokens are destroyed.1 parent a8f88bd commit d0096b3
File tree
42 files changed
+2107
-345
lines changed- src
- AppInstallerCLICore
- Commands
- Public
- AppInstallerCLIE2ETests
- Interop
- AppInstallerCLITests
- AppInstallerCommonCore
- Public
- Microsoft.Management.Configuration.UnitTests
- Fixtures
- Tests
- Microsoft.Management.Configuration
- Microsoft.Management.Deployment
- WinGetTestCommon
- WindowsPackageManager
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
42 files changed
+2107
-345
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
212 | 216 | | |
213 | 217 | | |
214 | 218 | | |
| |||
968 | 972 | | |
969 | 973 | | |
970 | 974 | | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
971 | 993 | | |
972 | 994 | | |
973 | 995 | | |
| |||
994 | 1016 | | |
995 | 1017 | | |
996 | 1018 | | |
| 1019 | + | |
| 1020 | + | |
997 | 1021 | | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
998 | 1025 | | |
999 | 1026 | | |
1000 | 1027 | | |
1001 | 1028 | | |
1002 | 1029 | | |
1003 | 1030 | | |
1004 | 1031 | | |
| 1032 | + | |
1005 | 1033 | | |
1006 | 1034 | | |
1007 | 1035 | | |
1008 | 1036 | | |
1009 | 1037 | | |
| 1038 | + | |
1010 | 1039 | | |
1011 | 1040 | | |
1012 | 1041 | | |
| |||
1016 | 1045 | | |
1017 | 1046 | | |
1018 | 1047 | | |
| 1048 | + | |
1019 | 1049 | | |
1020 | 1050 | | |
1021 | 1051 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
347 | 347 | | |
348 | 348 | | |
349 | 349 | | |
| 350 | + | |
350 | 351 | | |
351 | 352 | | |
352 | 353 | | |
| |||
421 | 422 | | |
422 | 423 | | |
423 | 424 | | |
| 425 | + | |
424 | 426 | | |
425 | 427 | | |
426 | 428 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
293 | 293 | | |
294 | 294 | | |
295 | 295 | | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
296 | 299 | | |
297 | 300 | | |
298 | 301 | | |
| |||
556 | 559 | | |
557 | 560 | | |
558 | 561 | | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
559 | 565 | | |
560 | 566 | | |
561 | 567 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | | - | |
| 23 | + | |
23 | 24 | | |
24 | | - | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | | - | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
43 | | - | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| |||
0 commit comments