ws2_32: Fix setsockopt(TCP_NODELAY) when optlen is less than 4.
According to MSDN [1], the `TCP_NODELAY` parameter should be of type
`BOOL` which is 4 bytes. Due to a bug [2] in rustc passing a byte
instead of an int, any program written in rust that tries to set that
option on a socket will fail with a "Invalid parameter supplied" error.
Turns out that setsockopt on linux does not want optlen to be less than
4 bytes [3].
Windows' behavior is the following:
- For optlen <= 0, return SOCKET_ERROR and set last error to WSAEFAULT
- For optlen > 0, ignore the optlen value and set the TCP_NODELAY value
to one if the first byte of the given optvalue is not 0.
This will fix any rust program using the hyper library to do HTTP
requests.
[1]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-tcp-socket-options
[2]: https://github.com/rust-lang/rust/blob/44593aeb1387b1be355aeaf0040d5927bd80f060/library/std/src/sys/windows/net.rs#L470
[3]: https://github.com/torvalds/linux/blob/d58071a8a76d779eedab38033ae4c821c30295a5/net/ipv4/tcp.c#L3419-L3420Signed-off-by: Bastien Orivel <eijebong@bananium.fr>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
Showing
Please
register
or
sign in
to comment