Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use BOOL for TCP_NODELAY setsockopt value on Windows #94094

Merged
merged 3 commits into from
Mar 1, 2022

Commits on Feb 21, 2022

  1. Fix setsockopt and getsockopt parameter names.

    Previously `level` was named `opt` and `option_name` was named `val`,
    then extra names of `payload` or `slot` were used for the option value.
    This change aligns the wrapper parameters with their names in POSIX.
    Winsock uses similar but more abbreviated names: `level`, `optname`,
    `optval`, `optlen`.
    chrisnc committed Feb 21, 2022
    Configuration menu
    Copy the full SHA
    3eb983e View commit details
    Browse the repository at this point in the history
  2. Remove assertion on output length for getsockopt.

    POSIX allows `getsockopt` to set `*option_len` to a smaller value if
    necessary. Windows will set `*option_len` to 1 for boolean options even
    when the caller passes a `BOOL` (`int`) with `*option_len` as 4.
    chrisnc committed Feb 21, 2022
    Configuration menu
    Copy the full SHA
    f2ebd0a View commit details
    Browse the repository at this point in the history
  3. use BOOL for TCP_NODELAY setsockopt value on Windows

    This issue was found by the Wine project and mitigated there [1].
    
    Windows' documented interface for `setsockopt` expects a `BOOL` (a
    `typedef` for `int`) for `TCP_NODELAY` [2]. Windows is forgiving and
    will accept any positive length and interpret the first byte of
    `*option_value` as the value, so this bug does not affect Windows
    itself, but does affect systems implementing Windows' interface more
    strictly, such as Wine. Wine was previously passing this through to the
    host's `setsockopt`, where, e.g., Linux requires that `option_len` be
    correct for the chosen option, and `TCP_NODELAY` expects an `int`.
    
    [1]: https://source.winehq.org/git/wine.git/commit/d6ea38f32dfd3edbe107a255c37e9f7f3da06ae7
    [2]: https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-setsockopt
    chrisnc committed Feb 21, 2022
    Configuration menu
    Copy the full SHA
    b02698c View commit details
    Browse the repository at this point in the history