Open database64128 opened 2 weeks ago
I suggest a doc change. The point of this function in the net package is to determine the maximum permitted backlog argument, not the "optimal" backlog argument.
This function could easily be written as an external package. It doesn't really belong in the net package; as far as I know there are no functions in the net package that take a backlog argument. We could consider adding MaxListenerBacklog
to the x/sys/unix package (there's not much point to adding it to x/sys/windows or x/sys/plan9, as on those systems there is nothing to look up).
I suggest a doc change. The point of this function in the net package is to determine the maximum permitted backlog argument, not the "optimal" backlog argument.
Thanks. Updated per your suggestion.
This function could easily be written as an external package. It doesn't really belong in the net package; as far as I know there are no functions in the net package that take a backlog argument. We could consider adding
MaxListenerBacklog
to the x/sys/unix package (there's not much point to adding it to x/sys/windows or x/sys/plan9, as on those systems there is nothing to look up).
I would prefer to have this function available on all platforms, just like how the unexported one in net
is, so it's easier for people to switch from linknaming against net.listenerBacklog
. It would also match the signature of syscall.Listen
.
But I guess only adding MaxListenerBacklog
to x/sys/unix
works for me too, as tfo-go only uses this on Linux.
Proposal Details
The
listenerBacklog
function returns a cached value of theoptimalmaximum permitted listener backlog on the current system, obtained in platform-specific ways. This is useful for user code that makes directlisten(2)
syscalls and then callsnet.FileListener
to create anet.Listener
.Since the function signature is unlikely to change in the future, and we already had it exempted from the linkname restriction, I propose we add: