Skip to content

Fix Windows wepoll initialization failure detection - #909

Merged
ithewei merged 1 commit into
ithewei:masterfrom
radkesvat:fix/wepoll-null-handle
Oct 20, 2026
Merged

ithewei merged 1 commit into
ithewei:masterfrom
radkesvat:fix/wepoll-null-handle

Conversation

@radkesvat

Copy link
Copy Markdown
Contributor

When wepoll epoll_create() fails on Windows, it returns NULL. iowatcher_init() currently checks epfd < 0, so it publishes a non-null watcher context containing a null native handle and reports successful initialization. A later registration fails, and subsequent additions reuse that invalid context instead of retrying creation.

Check epfd == NULL under OS_WIN, retaining the existing < 0 check on Linux. A failed creation now returns before allocating or publishing the context, so a later registration can retry. This follows the bundled wepoll contract.

The new Windows epoll_init_test injects one creation failure, then uses real wepoll ports to check successful retry, idempotent initialization, native handle validity and closure, cleanup, and ordinary recreation. Its checks remain active in Release builds. CMake includes the target when BUILD_UNITTEST=ON and WITH_WEPOLL=ON on Windows.

hio_add() already reports registration failure through the existing epoll_ctl() check. This patch fixes initialization state and retry; it does not change that public return convention or repeat the Linux error-propagation changes from PR #837.

@ithewei
ithewei merged commit 060a4b6 into ithewei:master Oct 20, 2026
6 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