forked from ocaml/ocaml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent erroneously waiting for an unbounded time in Unix.select
The documentation of `Unix.select _ _ _ s` reads: > The fourth argument is the maximal timeout, in seconds; a negative > fourth argument means no timeout (unbounded wait). This fixes a potential bug on Windows with the implementation of `Unix.select`. If a file descriptor list exceeds `FD_SETSIZE` (64 elements by default), or if one of the lists contains at least one fd that's not a socket, then [`select`][1] is emulated. In this code path, if the timeout ends up equating the sentinel value for an unbounded wait (`INFINITE` in the WinAPI, equal to $2^{32}$), then the wait becomes unbounded. This breaks the semantics of [Unix.select]. Cap the timeout to $2^{32}$ milliseconds. [1]: https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-select
- Loading branch information
Showing
4 changed files
with
18 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters