You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Synchronize with destroying spawned tasks more in wasip2
This commit fixes a test failure I'm running into in wasi-libc
development where spawned tasks for wasip2 are keeping objects alive in
a race condition where sometimes the task is torn down and sometimes
it's not. Specifically wasip2 is built on wasip3-style primitives for
UDP/TCP which means that futures are used, and if futures aren't
immediately ready they're resolved in a spawned Tokio task. This spawned
task can interact with UDP, for example, where exclusivity of a UDP
socket is tested via `Arc::get_mut` which will nondeterministically
return true or false depending if a previously spawned task has exited
or not. In wasi-libc this means that reconnecting a UDP socket sometimes
fails and sometimes passes because the background task may or may not
have exited.
Here this is resolved by making the `drop` methods async and then
hooking into the preexisting `cancel` method which aborts the task and
then waits on the result. This synchronizes with the task to ensure that
the state of the socket is guaranteed to be exclusive after a disconnect
and ready for another connect. This similar fix is then applied to
ip-name-lookup as well.
0 commit comments