Refactor poll_oneoff on *nix (#137)
* Fixes CraneStation/wasmtime#440 This commit introduces a couple of changes/fixes: * it annotates `log::debug!` messages with "host" to differentiate between file descriptors stored on the WASI side (aka the wrappers) and those managed by the host (aka the wrapped) * it fixes CraneStation/wasmtime#440, i.e., incorrect passing of file descriptor to `poll_oneoff` where currently errenously we pass in the wrapper instead of the wrapped value * it adds a couple more `log::debug!` macros calls for easier future debugging * Add partial refactorting to poll_oneoff This commit lays the groundwork for more clean up to come in subsequent commits. * Finalise refactoring of `poll_oneoff` * Fix compilation error on Windows * Address majority of suggestions and refactor Co-authored-by: Marcin Mielniczuk <marmistrz.dev@zoho.eu> * Add poll_oneoff test case * Leave timeout in nanoseconds in ClockEventData Instead of converting the timeout value from nanoseconds to milliseconds in the host-independent impl, move the conversion to *nix-specific impl as the conversion is currently only warranted by the POSIX `poll` syscall. * Don't fail immediately on bad descriptor If the user specifies an invalid descriptor inside a subscription, don't fail immediately but rather generate an event with the thrown WASI error code, and continue with the remaining, potentially correct subscriptions.
This commit is contained in:
@@ -134,7 +134,9 @@ impl WasiCtxBuilder {
|
||||
}
|
||||
let mut fe = FdEntry::from(dir)?;
|
||||
fe.preopen_path = Some(guest_path);
|
||||
log::debug!("WasiCtx inserting ({:?}, {:?})", preopen_fd, fe);
|
||||
self.fds.insert(preopen_fd, fe);
|
||||
log::debug!("WasiCtx fds = {:?}", self.fds);
|
||||
preopen_fd = preopen_fd.checked_add(1).ok_or(Error::ENFILE)?;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user