Commit f672e27
committed
Fix race condition in async
Previously, we refactored the `GossipVerifier` to not require holding a
circular reference. As part of this, we moved to a model where the
`UtxoFuture`s are now polled by the background processor which checks
for completion through `get_and_clear_pending_msg_events`.
However, as part of this refactor we introduced race-condition: as we
only held `Weak` references in `PendingChecksContext` and the
`UtxoFuture` was directly dropped by the `GossipVerifier` after calling
`resolve`, the actual data was dropped with the future and gone when the
background processor attempted to retrieve and apply it via
`check_resolved_futures`.
Here, we fix this issue by simply holding on to the `state` `Arc`s in a
separate `pending_states` `Vec` that is only pruned in
`check_resolved_futures`, ensuring any completed results are collected
first.
Signed-off-by: Elias Rohrer <dev@tnull.de>UtxoFuture resolution1 parent 1fafc83 commit f672e27
1 file changed
Lines changed: 30 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| 169 | + | |
169 | 170 | | |
170 | 171 | | |
171 | 172 | | |
| |||
180 | 181 | | |
181 | 182 | | |
182 | 183 | | |
| 184 | + | |
183 | 185 | | |
184 | 186 | | |
185 | 187 | | |
| |||
413 | 415 | | |
414 | 416 | | |
415 | 417 | | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
416 | 430 | | |
417 | 431 | | |
418 | 432 | | |
| |||
574 | 588 | | |
575 | 589 | | |
576 | 590 | | |
577 | | - | |
578 | | - | |
579 | | - | |
580 | | - | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
581 | 599 | | |
582 | 600 | | |
| 601 | + | |
583 | 602 | | |
584 | 603 | | |
585 | | - | |
586 | | - | |
587 | | - | |
588 | 604 | | |
589 | 605 | | |
| 606 | + | |
590 | 607 | | |
591 | | - | |
592 | | - | |
593 | | - | |
594 | | - | |
595 | | - | |
596 | | - | |
597 | | - | |
598 | | - | |
599 | | - | |
600 | | - | |
601 | | - | |
602 | | - | |
603 | | - | |
| 608 | + | |
604 | 609 | | |
605 | 610 | | |
606 | 611 | | |
| |||
1081 | 1086 | | |
1082 | 1087 | | |
1083 | 1088 | | |
1084 | | - | |
| 1089 | + | |
1085 | 1090 | | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
1086 | 1095 | | |
1087 | 1096 | | |
1088 | 1097 | | |
0 commit comments