Repository navigation
Conversation
|
Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: TStal.
|
On Windows a SOCKET is an opaque handle, not a small index, and an fd_set is a counted array of sockets rather than a bitmask. libmodbus only ever puts a single socket in a set, so it can't overflow it. The fd >= FD_SETSIZE checks added in 7b13341 therefore don't apply on Windows, where they instead reject any socket whose handle value reaches FD_SETSIZE (64 by default) - which happens after a few dozen open handles and breaks Modbus TCP with EINVAL / "exceeds FD_SETSIZE". Wrap the check in a macro that keeps it on POSIX and disables it on Windows. POSIX behaviour is unchanged. Fixes stephane#842
fde8276 to
24f6be6
Compare
|
We require contributors to sign our Contributor License Agreement. In order for us to review and merge your code, please fill https://forms.gle/5635zjphDo5JEJQSA to get added. Your document will be manually checked by the maintainer. Be patient... |
|
Confirmed on 3.2.0 (a9b025d), Windows 11 x64, MSVC 2022. We build 3.2.0 with an equivalent change (no This PR does not cover a related problem. |
On Windows a SOCKET is an opaque handle, not a small index, and an fd_set is a counted array of sockets rather than a bitmask. libmodbus only ever puts a single socket in a set, so it can't overflow it.
The fd >= FD_SETSIZE checks added in 7b13341 therefore don't apply on Windows, where they instead reject any socket whose handle value reaches FD_SETSIZE (64 by default) - which happens after a few dozen open handles and breaks Modbus TCP with EINVAL / "exceeds FD_SETSIZE".
Wrap the check in a macro that keeps it on POSIX and disables it on Windows. POSIX behaviour is unchanged.
Fixes #842