Skip to content

Fix timestamps and add IOCTL support for nbytes #301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mmori7
Copy link

@mmori7 mmori7 commented May 2, 2025

This commit adds functionality to the uvwasi poll_oneoff implementation by reporting the number of bytes available to read for file descriptors. It uses ioctl with FIONREAD on Unix-like systems and ioctlsocket for socket types on Windows to properly populate the nbytes field in FD_READ events. Additionally, it adds the necessary system headers for these ioctl calls with appropriate platform-specific handling. The change helps applications know exactly how many bytes they can read without blocking, improving performance by allowing them to allocate buffers of the correct size.

This commit adds functionality to the uvwasi poll_oneoff implementation by reporting the number of bytes available to read for file descriptors. It uses ioctl with FIONREAD on Unix-like systems and ioctlsocket for socket types on Windows to properly populate the nbytes field in FD_READ events. Additionally, it adds the necessary system headers for these ioctl calls with appropriate platform-specific handling.
The change helps applications know exactly how many bytes they can read without blocking, improving performance by allowing them to allocate buffers of the correct size.
@Ronitsabhaya75
Copy link

The cross-platform approach with appropriate handling for both Unix and Windows is well-implemented, particularly the special consideration for Windows which doesn't support FIONREAD for non-socket descriptors. The error handling also looks robust, gracefully falling back to zero bytes when ioctl operations fail.

@cjihrig
Copy link
Collaborator

cjihrig commented May 29, 2025

@mmori7 the CI is failing.

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.

3 participants