@@ -102,6 +102,11 @@ enum State {
102102 set : u32 ,
103103 waitable : u32 ,
104104 params : * mut SleepParams ,
105+ } ,
106+ S4 {
107+ set : u32 ,
108+ waitable : u32 ,
109+ params : * mut SleepParams ,
105110 params2 : * mut u64 ,
106111 } ,
107112}
@@ -292,17 +297,39 @@ unsafe extern "C" fn callback_run(event0: u32, event1: u32, event2: u32) -> u32
292297
293298 let result = subtask_cancel_async ( waitable) ;
294299
295- // NB: As of this writing, Wasmtime does *not* spawn a new fiber
296- // for async->async guest calls, which means we'll block
297- // synchronously when calling `subtask_cancel_async` even though
298- // we're calling it with the `async` canonical option. The
299- // following assertion relies on that behavior; it will need to
300- // be changed ( and this test case refactored) if/when that
301- // behavior changes.
302- assert_eq ! ( result, STATUS_RETURN_CANCELLED ) ;
300+ // NB: As of this writing, Wasmtime spawns a new fiber for
301+ // async->async guest calls, which means the above call should
302+ // block asynchronously, giving us back control. However, the
303+ // runtime could alternatively execute the call on the original
304+ // fiber, in which case the above call would block synchronously
305+ // and return `STATUS_RETURN_CANCELLED`. If Wasmtime's behavior
306+ // changes, this test will need to be modified .
307+ assert_eq ! ( result, BLOCKED ) ;
303308
304- waitable_join ( waitable, 0 ) ;
305- subtask_drop ( waitable) ;
309+ waitable_join ( waitable, * set) ;
310+
311+ let set = * set;
312+
313+ * state = State :: S3 {
314+ set,
315+ waitable,
316+ params : * params,
317+ } ;
318+
319+ CALLBACK_CODE_WAIT | ( set << 4 )
320+ }
321+
322+ State :: S3 {
323+ set,
324+ waitable,
325+ params,
326+ } => {
327+ assert_eq ! ( event0, EVENT_SUBTASK ) ;
328+ assert_eq ! ( event1, * waitable) ;
329+ assert_eq ! ( event2, STATUS_RETURN_CANCELLED ) ;
330+
331+ waitable_join ( * waitable, 0 ) ;
332+ subtask_drop ( * waitable) ;
306333
307334 // Next, call and cancel `sleep::sleep_millis`, which the callee
308335 // implements using both an synchronous lift and asynchronous
@@ -327,7 +354,7 @@ unsafe extern "C" fn callback_run(event0: u32, event1: u32, event2: u32) -> u32
327354
328355 let set = * set;
329356
330- * state = State :: S3 {
357+ * state = State :: S4 {
331358 set,
332359 waitable,
333360 params : * params,
@@ -337,7 +364,7 @@ unsafe extern "C" fn callback_run(event0: u32, event1: u32, event2: u32) -> u32
337364 CALLBACK_CODE_WAIT | ( set << 4 )
338365 }
339366
340- State :: S3 {
367+ State :: S4 {
341368 set,
342369 waitable,
343370 params,
0 commit comments