Commit 73c2ce3
authored
Enable cancellation for anonymous pipes and non-async named pipes on Windows (#72503)
* Enable cancellation for anonymous pipes and non-async named pipes on Windows
Although ReadAsync, WriteAsync, and WaitForConnectionAsync on pipes all accept a CancellationToken, that token is only usable on Windows for canceling an in-flight operation when the pipe is using overlapped I/O. If the pipe was created for non-overlapped I/O, as is the case for anonymous pipes and can be the case for named pipes, the token stops being useful for anything other than an up-front cancellation check.
This change fixes that by using CancelSynchronousIo to cancel the synchronous I/O performed as part of these async operations, which are implemented as async-over-sync (queueing to the thread pool a work item that performs the synchronous I/O).
(The Unix implementation already supports cancellation in these situations.)
* Address PR feedback (tweak comments)1 parent c046354 commit 73c2ce3
File tree
10 files changed
+398
-119
lines changed- src/libraries
- Common
- src
- Interop/Windows/Kernel32
- Microsoft/Win32/SafeHandles
- tests/StreamConformanceTests/System/IO
- System.Diagnostics.Process/src
- Microsoft/Win32/SafeHandles
- System.IO.Pipes
- src
- System/IO/Pipes
- tests
10 files changed
+398
-119
lines changedLines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
11 | 13 | | |
12 | | - | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
Lines changed: 18 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
529 | 529 | | |
530 | 530 | | |
531 | 531 | | |
532 | | - | |
| 532 | + | |
533 | 533 | | |
534 | 534 | | |
535 | 535 | | |
536 | 536 | | |
537 | 537 | | |
538 | 538 | | |
539 | 539 | | |
| 540 | + | |
540 | 541 | | |
541 | | - | |
| 542 | + | |
| 543 | + | |
542 | 544 | | |
543 | 545 | | |
544 | 546 | | |
545 | | - | |
| 547 | + | |
546 | 548 | | |
547 | 549 | | |
548 | 550 | | |
549 | 551 | | |
550 | 552 | | |
551 | 553 | | |
552 | 554 | | |
| 555 | + | |
553 | 556 | | |
554 | | - | |
| 557 | + | |
| 558 | + | |
555 | 559 | | |
556 | 560 | | |
557 | 561 | | |
| |||
1671 | 1675 | | |
1672 | 1676 | | |
1673 | 1677 | | |
1674 | | - | |
| 1678 | + | |
| 1679 | + | |
| 1680 | + | |
1675 | 1681 | | |
1676 | 1682 | | |
1677 | | - | |
| 1683 | + | |
1678 | 1684 | | |
1679 | 1685 | | |
1680 | 1686 | | |
1681 | 1687 | | |
1682 | | - | |
| 1688 | + | |
1683 | 1689 | | |
1684 | 1690 | | |
1685 | | - | |
| 1691 | + | |
| 1692 | + | |
| 1693 | + | |
1686 | 1694 | | |
1687 | 1695 | | |
1688 | | - | |
| 1696 | + | |
1689 | 1697 | | |
1690 | 1698 | | |
1691 | 1699 | | |
1692 | 1700 | | |
1693 | | - | |
| 1701 | + | |
1694 | 1702 | | |
1695 | 1703 | | |
1696 | 1704 | | |
| |||
Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
| 214 | + | |
| 215 | + | |
214 | 216 | | |
215 | | - | |
216 | 217 | | |
217 | 218 | | |
218 | 219 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| |||
94 | 96 | | |
95 | 97 | | |
96 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
97 | 109 | | |
98 | 110 | | |
99 | 111 | | |
100 | 112 | | |
101 | 113 | | |
102 | 114 | | |
| 115 | + | |
103 | 116 | | |
104 | 117 | | |
105 | 118 | | |
| |||
108 | 121 | | |
109 | 122 | | |
110 | 123 | | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | 124 | | |
120 | 125 | | |
121 | 126 | | |
| |||
176 | 181 | | |
177 | 182 | | |
178 | 183 | | |
| 184 | + | |
179 | 185 | | |
180 | 186 | | |
181 | 187 | | |
| |||
Lines changed: 38 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
168 | 169 | | |
169 | 170 | | |
170 | 171 | | |
171 | | - | |
172 | | - | |
| 172 | + | |
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
| |||
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
186 | | - | |
| 186 | + | |
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
| 190 | + | |
190 | 191 | | |
191 | 192 | | |
192 | 193 | | |
193 | 194 | | |
194 | 195 | | |
| 196 | + | |
195 | 197 | | |
196 | 198 | | |
197 | 199 | | |
198 | 200 | | |
199 | | - | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
200 | 207 | | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
205 | 215 | | |
206 | | - | |
| 216 | + | |
| 217 | + | |
207 | 218 | | |
208 | | - | |
209 | | - | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
210 | 237 | | |
211 | | - | |
212 | | - | |
213 | 238 | | |
214 | 239 | | |
215 | 240 | | |
| |||
0 commit comments