Avoid calling poll_oneoff with zero subscriptions.#162
Conversation
|
Wouldn't it be preferable to immediately return |
|
This path should be very rare, and when it does happen, it probably means that applications need to change their code anyway, because WASI lacks signal handlers which you'd need to make meaningful use of it. |
|
Hmm, FWIW I agree with @marmistrz on this one. However, having said that, since this indeed should probe the dev to fix their app since we don't (and probably won't, right?) have signal handlers, I guess we're good to go here. |
|
Oh, and FWIW, the title is slightly misleading as at first read it sounds as if |
|
Ah, that's actually an error. I've now added a patch to this PR to fix this, which also clarifies my intent here: we should return Concerning whether we should check |
|
@marmistrz Does this PR with the change to not conflate |
|
I'll share my feedback tomorrow. |
|
There's one subtlety here that I'd like to see documented in a comment. Should we return an error based on We can see that if there's no timeout and wasi-libc/libc-bottom-half/cloudlibc/src/libc/poll/poll.c Lines 41 to 43 in 1a187b7 We could also add an assertion that |
|
I've now added comments explaining the nsubscriptions == 0. I assume the way to add support for pure |
|
The comment is unclear to me.
Such situation sounds like a bug to me, and it's impossible with current code.
Is this an explanation of the reason why we return |
|
It's better now, but now it's not mentioned nor asserted that |
|
It's much better now. But shouldn't a situation when
is missing a backtick :) |
It doesn't; if an event's
nsubscriptions == 0 with nfds > 0 would mean that the user gave us an array of subscriptions where all the
Fixed! |
With WebAssembly/WASI#193 merged, WASI is moving to make `poll_oneoff` with no arguments an error. Even though that's in ephemeral and not yet in a snapshot, we can start to anticipate it in libc: - Remove the `pause` function, since WASI has no signals and thus no way to ever wake it up short of having the host terminate it. - Make `poll` and `pselect` return `ENOTSUP` in the case of having no events to wait for.
Make `poll` and `pselect` return `ENOTSUP` when asked to poll on zero subscriptions, rather than when the systerm returns zero events. While here, drop the `__wasilibc_unmodified_upstream` markers, which were already pretty noisy here, and would be significantly worse with this change.
|
Thanks! |
With WebAssembly/WASI#193 merged, WASI is moving
to make
poll_oneoffwith no arguments an error. Even though that's inephemeral and not yet in a snapshot, we can start to anticipate it in
libc:
pausefunction, since WASI has no signals and thus noway to ever wake it up short of having the host terminate it.
pollandpselectreturnENOTSUPin the case of having noevents to wait for.