You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Positive sub-microsecond socket timeouts disable the timeout on POSIX #220
On POSIX, a positive socket timeout shorter than one microsecond is converted to a zero timeval. SO_RCVTIMEO and SO_SNDTIMEO interpret zero as no timeout, so a small positive deadline can turn into an unbounded blocking operation.
Regression coverage first: test/regression/SocketTinyTimeout, in the existing regression layout. Connect two loopback sockets. Have the peer send one byte after 100 ms so the test remains bounded even when the timeout is disabled. A read with timeout 0.0000001 seconds should time out before the byte arrives. Repeat with 0.01 seconds as a control and wait for the sender to finish before closing sockets.
Confirmed on Linux x86_64 with Haxe 4.3.3:
tiny positive timeout expired: false
normal positive timeout expired: true
In src/hx/libs/std/Socket.cpp, socket_set_timeout truncates the fractional part to integer microseconds. The POSIX branch does not ensure that a positive request produces a nonzero timeval. The Windows branch already has the equivalent guard for positive sub-millisecond values.
Round a positive timeout up to the platform's minimum nonzero representation. Keep exactly zero and null as the existing no-timeout setting. Cover values below one microsecond, normal fractional values and the boundary near a full second, and avoid producing an invalid tv_usec of 1000000 through rounding.
The reproduction is Linux-only. This is separate from interrupted select/poll deadlines: the timeout is disabled before the receive operation even starts. No runtime implementation changes are included.
Activity
Round a sub-microsecond socket timeout up on POSIX