Skip to content

Conversation

@dimensionscape
Copy link
Contributor

…ents` on error/empty sets

Previously, _hx_std_socket_poll_events could exit early on select()/poll() errors without resetting the ready index arrays. This left stale values in p->ridx/p->widx, causing incorrect results when the socket set was empty or when sockets were removed. In Haxe this manifested as phantom entries (e.g. index "1" still marked ready after deregistration, or poll([]) returning [null]).

This change ensures p->ridx[0] and p->widx[0] are always initialized to -1 at function entry, and remain consistent even if select()/poll() returns an error. With this fix, empty socket sets no longer yield spurious ready indexes, and poll() on an empty registry correctly returns [] without mutating the input array.

…ents` on error/empty sets

Previously, `_hx_std_socket_poll_events` could exit early on `select()/poll()` 
errors without resetting the ready index arrays. This left stale values 
in `p->ridx/p->widx`, causing incorrect results when the socket set was 
empty or when sockets were removed. In Haxe this manifested as phantom 
entries (e.g. index "1" still marked ready after deregistration, or 
`poll([])` returning `[null]`).

This change ensures `p->ridx[0]` and `p->widx[0]` are always initialized 
to `-1` at function entry, and remain consistent even if `select()/poll()` 
returns an error. With this fix, empty socket sets no longer yield 
spurious ready indexes, and poll() on an empty registry correctly 
returns `[]` without mutating the input array.
@dimensionscape dimensionscape deleted the patch-3 branch August 22, 2025 14:50
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.

1 participant