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

Make accept() ENFILE stop spamming the log #71

Closed
nmathewson opened this issue Aug 1, 2013 · 7 comments
Closed

Make accept() ENFILE stop spamming the log #71

nmathewson opened this issue Aug 1, 2013 · 7 comments

Comments

@nmathewson
Copy link
Member

On libevent-users, Adrian Chadd and Oleg Moskalenko report that it's annoying to have evconnlistener report ENFILE over and over when the file table is full. And it is!

There's a workaround, where you set the error handler for the listener to disable the listener if the error was ENFILE, and the you re-enable the listener once you've closed a socket or a few seconds have gone by or something.

There's another "workaround", where you use the logging functions to make it so that log callbacks don't go to stderr. But that's not much comfort.

What can Libevent do better here on its own? Rate-limiting logs could be an option, I guess, though I hesitate to step in that direction.

Documenting the first workaround above might also rock. (Also, we should test to make sure that it works before I go and claim that it's what people should be doing.)

@nirs
Copy link
Contributor

nirs commented Aug 2, 2013

It would be useful if the listener would report back such error to the application, which can handle the situation (e.g terminating).

Something like this:

When a new connection is received, the provided callback function is invoked. The listener
argument is the connection listener that received the connection. The sock argument is the
new socket itself. If accepting the new connection failed, the sock argument is -1, and errno
is set to the accept error. The addr and len arguments are the address from which the connection
was received and the length of that address respectively. The ptr argument is the user-supplied
pointer that was passed to evconnlistener_new().

This change will break old code - probably needs more thinking.

@nmathewson
Copy link
Member Author

I'm still waking up, but is the current error callback that you can set on an evconnlistener with evconnlistener_set_error_cb() not adequate for what you describe? It doesn't receive an address, but in the case of an error, I believe no address is available.

@nirs
Copy link
Contributor

nirs commented Aug 3, 2013

The error callback is much better then the hack I suggested. Can you get errno value in this callback?

@nirs
Copy link
Contributor

nirs commented Aug 3, 2013

Ok, the example in the libevent book show that it should work. So the only issue here is not spamming the logs.

@nirs
Copy link
Contributor

nirs commented Aug 3, 2013

Looking at the code, I think there is no issue here - you get a warning only if you did not register an error handler.

if (lev->errorcb != NULL) {
    ...
    errorcb(lev, user_data);
    ....
} else {
    event_sock_warn(fd, "Error from accept() call");
}

If you do not like these warnings, register an error handler.

@nmathewson
Copy link
Member Author

Okay. So, any reason not to close this ?

@nirs
Copy link
Contributor

nirs commented Aug 4, 2013

I don't see one :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants