Skip to content

Commit 30be75e

Browse files
authored
fix recursive async_support::poll calls (#1166)
Previously, a recursive call would overwrite the `CURRENT` global variable; now we save the old value so we can restore it later. Signed-off-by: Joel Dice <joel.dice@fermyon.com>
1 parent 0853cc5 commit 30be75e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

crates/guest-rust/rt/src/async_support.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,10 @@ fn dummy_waker() -> Waker {
9494
unsafe fn poll(state: *mut FutureState) -> Poll<()> {
9595
loop {
9696
if let Some(futures) = (*state).tasks.as_mut() {
97+
let old = CURRENT;
9798
CURRENT = state;
9899
let poll = futures.poll_next_unpin(&mut Context::from_waker(&dummy_waker()));
99-
CURRENT = ptr::null_mut();
100+
CURRENT = old;
100101

101102
if SPAWNED.is_empty() {
102103
match poll {

0 commit comments

Comments
 (0)