Repository navigation
Commit b3d9965
committed
[BUG] Publish the completion callback before the first event
Cleanup() takes is_cleaned_ at its start and swaps async_data_->callback about
forty lines later, so the is_cleaned_ recheck in SendAsync only says cleanup
has begun, not that it has finished reading the callback.
A handler cancelling from the Connecting event wakes the IO thread, which can
reach the swap before SendAsync stores the callback. Cleanup then finds an
empty one, the completion never runs, and the lambda that clears
is_session_active_ never runs with it, so the session stays active for good.
The two accesses to the std::function also race.
The callback is published with the flags and the session route now, before the
event. The future stays behind it, so a handler calling FinishSession() from
that event still returns rather than waiting on a transfer that has not been
scheduled.
Found by @lalitb in review.
Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>1 parent 73f5f82 commit b3d9965
2 files changed
Lines changed: 16 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1452 | 1452 | | |
1453 | 1453 | | |
1454 | 1454 | | |
1455 | | - | |
1456 | | - | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
1457 | 1460 | | |
1458 | 1461 | | |
1459 | 1462 | | |
1460 | | - | |
| 1463 | + | |
| 1464 | + | |
1461 | 1465 | | |
1462 | 1466 | | |
1463 | 1467 | | |
1464 | | - | |
1465 | | - | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
1466 | 1471 | | |
1467 | 1472 | | |
1468 | | - | |
1469 | 1473 | | |
1470 | 1474 | | |
1471 | 1475 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
593 | 593 | | |
594 | 594 | | |
595 | 595 | | |
596 | | - | |
597 | | - | |
598 | | - | |
599 | | - | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
600 | 600 | | |
601 | 601 | | |
602 | 602 | | |
| |||
640 | 640 | | |
641 | 641 | | |
642 | 642 | | |
643 | | - | |
644 | | - | |
| 643 | + | |
| 644 | + | |
645 | 645 | | |
646 | 646 | | |
647 | 647 | | |
| |||
0 commit comments