Skip to content

Commit 34ede54

Browse files
committed
fix: add check on returned events
1 parent f841c26 commit 34ede54

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,8 @@ execute_interruptible_poll_oneoff(
10081008

10091009
wasi_errno_t err;
10101010
__wasi_timestamp_t elapsed = 0;
1011+
bool all_outs_are_type_clock;
1012+
uint32 i;
10111013

10121014
const __wasi_timestamp_t timeout = get_timeout_for_poll_oneoff(
10131015
in, nsubscriptions),
@@ -1041,11 +1043,17 @@ execute_interruptible_poll_oneoff(
10411043
wasm_runtime_free(in_copy);
10421044
return EINTR;
10431045
}
1044-
else if (*nevents > 0
1045-
&& !(nsubscriptions == 1
1046-
&& in[0].u.type == __WASI_EVENTTYPE_CLOCK)) {
1047-
wasm_runtime_free(in_copy);
1048-
return __WASI_ESUCCESS;
1046+
else if (*nevents > 0) {
1047+
all_outs_are_type_clock = true;
1048+
for (i = 0; i < nsubscriptions; i++) {
1049+
if (out[i].type != __WASI_EVENTTYPE_CLOCK)
1050+
all_outs_are_type_clock = false;
1051+
}
1052+
1053+
if (!all_outs_are_type_clock) {
1054+
wasm_runtime_free(in_copy);
1055+
return __WASI_ESUCCESS;
1056+
}
10491057
}
10501058
}
10511059

0 commit comments

Comments
 (0)