hxcpp
hxcpp copied to clipboard
[fix] Socket: Fix stale indexes and surface close/error reliably in _hx_std_socket_poll_events
This PR contains two related fixes in _hx_std_socket_poll_events to make
polling safer and more consistent:
-
Clear ridx/widx on entry and early return
Prevents stale values when polling with empty registries or when select()/poll() errors out. Previously this could result in phantom indexes or poll([]) returning [null]. -
Surface close/error conditions reliably
-
Windows: now pass and handle an
exceptfdsset to detect errors and connection resets. OnSOCKET_ERROR, all current read fds are surfaced so userland can clean up. -
POSIX: include
POLLERR | POLLNVALalongsidePOLLIN/HUPandPOLLOUT/HUPso teardown/error conditions are not missed.
-
Windows: now pass and handle an
Together these changes ensure that:
- Empty registries return no ready sockets.
- Closed/reset sockets always show up as "ready" for one tick so userland can detect EOF and deregister them.
- The behavior is consistent across Windows and POSIX backends.