Skip to content

Fix timeout in poll_oneoff#1980

Merged
wenyongh merged 8 commits intobytecodealliance:mainfrom
eloparco:eloparco/fix-poll-oneoff-timeout
Feb 23, 2023
Merged

Fix timeout in poll_oneoff#1980
wenyongh merged 8 commits intobytecodealliance:mainfrom
eloparco:eloparco/fix-poll-oneoff-timeout

Conversation

@eloparco
Copy link
Contributor

Two fixes in the poll_oneoff implementation:

  • wasm_runtime_get_exception() was being called after the proc_exit exception was cleared
    clear_wasi_proc_exit_exception(WASMModuleInstanceCommon *module_inst_comm)

    therefore it was always returning NULL; suspend_flags should be used instead to check for termination;
  • elapsed was incremented before the call to wasmtime_ssp_poll_oneoff()

Follow-up on #1951. Tested with multiple timeout values, with and without interruption and measuring the time spent sleeping.

@eloparco eloparco force-pushed the eloparco/fix-poll-oneoff-timeout branch from ce5bd0c to 9bedc46 Compare February 21, 2023 16:20
@eloparco eloparco force-pushed the eloparco/fix-poll-oneoff-timeout branch from 1a684af to b8067df Compare February 22, 2023 09:17
@eloparco eloparco force-pushed the eloparco/fix-poll-oneoff-timeout branch from 94be0a5 to d104f4e Compare February 22, 2023 10:10
@eloparco eloparco force-pushed the eloparco/fix-poll-oneoff-timeout branch from 972049e to a60167c Compare February 22, 2023 14:49
@eloparco eloparco force-pushed the eloparco/fix-poll-oneoff-timeout branch 2 times, most recently from 406cf99 to c020326 Compare February 22, 2023 16:31
@eloparco eloparco force-pushed the eloparco/fix-poll-oneoff-timeout branch from c020326 to e3823f4 Compare February 22, 2023 17:24
@eloparco eloparco requested a review from wenyongh February 23, 2023 00:17
Copy link
Collaborator

@wenyongh wenyongh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wenyongh wenyongh merged commit 63273a1 into bytecodealliance:main Feb 23, 2023
vickiegpt pushed a commit to vickiegpt/wamr-aot-gc-checkpoint-restore that referenced this pull request May 27, 2024
…ytecodealliance#1980)

Fix issues in the libc-wasi `poll_oneoff` when thread manager is enabled:
-  The exception of a thread may be cleared when other thread runs into
   `proc_exit` and then calls `clear_wasi_proc_exit_exception`, so should not
   use `wasm_runtime_get_exception` to check whether an exception was
    thrown, use `wasm_cluster_is_thread_terminated` instead
- We divided one time poll_oneoff into many times poll_oneoff to check
   the exception to avoid long time waiting in previous PR, but if all events
   returned by one time poll are all waiting events, we need to continue to
   wait but not return directly.

Follow-up on bytecodealliance#1951. Tested with multiple timeout values, with and without
interruption and measured the time spent sleeping.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants