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

proposal: net: export listenerBacklog #67990

Open
database64128 opened this issue Jun 14, 2024 · 2 comments
Open

proposal: net: export listenerBacklog #67990

database64128 opened this issue Jun 14, 2024 · 2 comments
Labels
Milestone

Comments

@database64128
Copy link
Contributor

database64128 commented Jun 14, 2024

Proposal Details

The listenerBacklog function returns a cached value of the optimal maximum permitted listener backlog on the current system, obtained in platform-specific ways. This is useful for user code that makes direct listen(2) syscalls and then calls net.FileListener to create a net.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:

// MaxListenerBacklog returns the maximum permitted listener backlog value on the current system.
// The return value may be used as the backlog argument to the listen(2) syscall.
func MaxListenerBacklog() int
@ianlancetaylor
Copy link
Contributor

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).

@gopherbot gopherbot added this to the Proposal milestone Jun 17, 2024
@database64128
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Incoming
Development

No branches or pull requests

3 participants