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: os: add ErrOutOfFileDescriptors #60281

Open
mateusz834 opened this issue May 18, 2023 · 2 comments
Open

proposal: os: add ErrOutOfFileDescriptors #60281

mateusz834 opened this issue May 18, 2023 · 2 comments
Labels
Milestone

Comments

@mateusz834
Copy link
Member

Currently there is no easy cross-platform way to detect the out of file descriptors error.

I propose adding a new error to the os package (os.ErrOutOfFileDescriptors) and adding support for it in syscall.Errno via the Is method (as already done with other errors like NoSuchFIle). So matching syscall.EMFILE, syscall.ENFILE on unix, syscall.EMFILE on other platforms.

I am still unsure about the name os.ErrOutOfFileDescriptors or os.ErrTooManyOpenFiles.

@gopherbot gopherbot added this to the Proposal milestone May 18, 2023
@ianlancetaylor
Copy link
Contributor

Can you point to some examples of code that would use this facility? Thanks.

@mateusz834
Copy link
Member Author

mateusz834 commented May 19, 2023

Mainly as an alternative to the deprecated Temporary() method (#45729), that is used in retry Accept() loops like this in net/http:

go/src/net/http/server.go

Lines 3059 to 3061 in d0c72c2

if ne, ok := err.(net.Error); ok && ne.Temporary() {
if tempDelay == 0 {
tempDelay = 5 * time.Millisecond

errors.Is(err, os.ErrOutOfFileDescriptors) is clearer about the expected behaviour than using the Temporary().

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