Skip to content

Fix os.poll dispatch when a later descriptor is ready - #1786

Merged
saghul merged 1 commit into
quickjs-ng:masterfrom
gengjiawen:fix-os-poll-nfds
Oct 1, 2026
Merged

saghul merged 1 commit into
quickjs-ng:masterfrom
gengjiawen:fix-os-poll-nfds

Conversation

@gengjiawen

Copy link
Copy Markdown
Contributor

Summary

js_os_poll_internal reused nfds for the return value of poll(). Since poll() returns the number of ready descriptors rather than the size of the input array, a ready descriptor after the first returned count was never inspected. The event loop then repeatedly observed the same ready descriptor and spun without dispatching its handler.

This change preserves the original descriptor count for the dispatch loop. The regression test registers two pipe handlers, makes only the second pipe readable, and uses a short timeout so the old behavior fails deterministically.

Validation

  • Release build with QJS_BUILD_WERROR=ON
  • tests/test_std.js
  • run-test262 -c tests.conf (0/117 errors, 9 excluded)
  • make jscheck ctest cxxtest

@saghul

saghul commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Ignore the windows failures, unrelated.

@saghul
saghul merged commit 1ea7ebd into quickjs-ng:master Oct 1, 2026
125 of 128 checks passed
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.

2 participants