Commit e004d42
worker: use special message as MessagePort close command
When a `MessagePort` connected to another `MessagePort` closes, the
latter `MessagePort` will be closed as well. Until now, this is done
by testing whether the ports are still entangled after processing
messages. This leaves open a race condition window in which messages
sent just before the closure can be lost when timing is unfortunate.
(A description of the timing is in the test file.)
This can be addressed by using a special message instead, which is
the last message received by a `MessagePort`. This way, all previously
sent messages are processed first.
Fixes: #22762
PR-URL: #27705
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>1 parent b7ed4d7 commit e004d42
File tree
3 files changed
+71
-36
lines changed- src
- test/parallel
3 files changed
+71
-36
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
43 | 47 | | |
44 | 48 | | |
45 | 49 | | |
| |||
91 | 95 | | |
92 | 96 | | |
93 | 97 | | |
| 98 | + | |
| 99 | + | |
94 | 100 | | |
95 | 101 | | |
96 | 102 | | |
| |||
395 | 401 | | |
396 | 402 | | |
397 | 403 | | |
| 404 | + | |
398 | 405 | | |
399 | 406 | | |
400 | 407 | | |
| |||
430 | 437 | | |
431 | 438 | | |
432 | 439 | | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | 440 | | |
439 | 441 | | |
440 | 442 | | |
| |||
443 | 445 | | |
444 | 446 | | |
445 | 447 | | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | 448 | | |
453 | 449 | | |
454 | 450 | | |
| |||
462 | 458 | | |
463 | 459 | | |
464 | 460 | | |
465 | | - | |
466 | | - | |
467 | | - | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
468 | 465 | | |
469 | | - | |
| 466 | + | |
470 | 467 | | |
471 | 468 | | |
472 | 469 | | |
| |||
590 | 587 | | |
591 | 588 | | |
592 | 589 | | |
593 | | - | |
594 | | - | |
595 | | - | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
596 | 597 | | |
| 598 | + | |
| 599 | + | |
597 | 600 | | |
598 | 601 | | |
599 | 602 | | |
600 | 603 | | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
601 | 609 | | |
602 | 610 | | |
603 | 611 | | |
| |||
628 | 636 | | |
629 | 637 | | |
630 | 638 | | |
631 | | - | |
632 | | - | |
633 | | - | |
634 | | - | |
635 | | - | |
636 | | - | |
637 | | - | |
638 | | - | |
639 | | - | |
640 | 639 | | |
641 | 640 | | |
642 | 641 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
20 | 23 | | |
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
24 | 27 | | |
25 | 28 | | |
26 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
27 | 34 | | |
28 | 35 | | |
29 | 36 | | |
| |||
89 | 96 | | |
90 | 97 | | |
91 | 98 | | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | 99 | | |
97 | 100 | | |
98 | 101 | | |
| |||
109 | 112 | | |
110 | 113 | | |
111 | 114 | | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | 115 | | |
117 | 116 | | |
118 | 117 | | |
| |||
178 | 177 | | |
179 | 178 | | |
180 | 179 | | |
181 | | - | |
182 | 180 | | |
183 | 181 | | |
184 | 182 | | |
| |||
Lines changed: 38 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 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
0 commit comments