Commit 5d29560
authored
Avoid sending EndStream after RST_STREAM with dedicated lock (#54552)
A race condition between sending RST_STREAM and checking conditions for sending EndStream was discovered during stress testing. It happens to be possible that in time after Http2Stream [checked the _responseCompletionState](https://github.com/dotnet/runtime/blob/183c4d100f68fb6c177a1fe71809d581aa25e47b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Stream.cs#L275) and [actually send EndStream](https://github.com/dotnet/runtime/blob/183c4d100f68fb6c177a1fe71809d581aa25e47b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Stream.cs#L288), a concurrent call to [Cancel method sends a RST_STREAM frame](https://github.com/dotnet/runtime/blob/183c4d100f68fb6c177a1fe71809d581aa25e47b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Stream.cs#L389). Such reordering is disallowed by HTTP/2 protocol.
Note: The issue and fix were verified manually under the debugger because currently it's not clear how to reliably simulate that situation.
Fixes #422001 parent 5f8a177 commit 5d29560
File tree
1 file changed
+20
-14
lines changed- src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler
1 file changed
+20
-14
lines changedLines changed: 20 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
| 248 | + | |
| 249 | + | |
248 | 250 | | |
249 | 251 | | |
250 | | - | |
251 | 252 | | |
252 | 253 | | |
253 | 254 | | |
| |||
275 | 276 | | |
276 | 277 | | |
277 | 278 | | |
278 | | - | |
279 | 279 | | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
289 | 290 | | |
290 | 291 | | |
291 | 292 | | |
| |||
325 | 326 | | |
326 | 327 | | |
327 | 328 | | |
328 | | - | |
| 329 | + | |
329 | 330 | | |
330 | 331 | | |
331 | 332 | | |
| |||
336 | 337 | | |
337 | 338 | | |
338 | 339 | | |
| 340 | + | |
| 341 | + | |
339 | 342 | | |
340 | 343 | | |
341 | 344 | | |
| |||
384 | 387 | | |
385 | 388 | | |
386 | 389 | | |
387 | | - | |
| 390 | + | |
388 | 391 | | |
389 | | - | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
390 | 396 | | |
391 | 397 | | |
392 | 398 | | |
| |||
0 commit comments