aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMauri de Souza Meneguzzo <mauri870@gmail.com>2023-12-02 15:11:36 +0000
committerDamien Neil <dneil@google.com>2024-01-08 18:52:56 +0000
commit8eaa7935db8c8b901f4dbb7d224a347bb3c33d7f (patch)
tree72c9c61590e2534d2535bf37811c35f1583b0b6a
parent759849187f51e40e36a507656485e34170f77497 (diff)
downloadgo-8eaa7935db8c8b901f4dbb7d224a347bb3c33d7f.tar.gz
go-8eaa7935db8c8b901f4dbb7d224a347bb3c33d7f.zip
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>
-rw-r--r--src/net/sock_windows.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/net/sock_windows.go b/src/net/sock_windows.go
index 5540135a2c..a519909bb0 100644
--- a/src/net/sock_windows.go
+++ b/src/net/sock_windows.go
@@ -11,8 +11,9 @@ import (
)
func maxListenerBacklog() int {
- // TODO: Implement this
- // NOTE: Never return a number bigger than 1<<16 - 1. See issue 5030.
+ // When the socket backlog is SOMAXCONN, Windows will set the backlog to
+ // "a reasonable maximum value".
+ // See: https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-listen
return syscall.SOMAXCONN
}