]> Cypherpunks.ru repositories - gostls13.git/commit
net: clarify maxListenerBacklog windows implementation
authorMauri de Souza Meneguzzo <mauri870@gmail.com>
Sat, 2 Dec 2023 15:11:36 +0000 (15:11 +0000)
committerDamien Neil <dneil@google.com>
Mon, 8 Jan 2024 18:52:56 +0000 (18:52 +0000)
commit8eaa7935db8c8b901f4dbb7d224a347bb3c33d7f
tree72c9c61590e2534d2535bf37811c35f1583b0b6a
parent759849187f51e40e36a507656485e34170f77497
net: clarify maxListenerBacklog windows implementation

The previous TODO comments were somewhat ambiguous. This aims to
provide a clearer understanding of the behavior on Windows.

Windows does not offer a way to peek at the current backlog length, this
is explicitly stated in the winapi for `listen`.

When set to `syscall.SOMAXCONN`, the OS dynamically adjusts the
backlog to a maximum reasonable value. It goes as far as the dotnet
runtime itself introducing a new version of `listen` that does not accept a
backlog parameter to help eliminate the confusion when comparing the
behavior with UNIXes.

The docs also mention that `SOMAXCONN_HINT(N)` can be used, and that
it clips the final computed value between (200, 65535), which suggests
windows might use a `uint16` to back this number. Either way it does not
matter since windows will adjust this value anyway, so I removed the
wrapping TODO as well.

See https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-listen

Change-Id: I7b2e7cb547467c4bfc572ef0477a58de8c772521
GitHub-Last-Rev: 34e74abffe8792c8709c73db4d7a5fa05f64b1d0
GitHub-Pull-Request: golang/go#63549
Reviewed-on: https://go-review.googlesource.com/c/go/+/535475
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/net/sock_windows.go