What to do w/accept when too-many-files-open

Eric Brown yogieric.list at gmail.com
Tue Jan 22 07:57:35 CET 2008


I have put my server socket into non-blocking mode and added a watcher.
Everything works fine. My callback gets called and I call accept. However,
when accept returns -1 with errno EMFILE (too many files open), I just exit
out of my callback. But it is called again immediately.

I suppose at this point I could count the number of file descriptors my
program is using, stop the watcher, and when one of my file descriptors is
closed, start accepting again. Not only is that tedious, but I'm not even
sure it works as I think the reason I got into this state is old crashed
clients in time-wait state.

Instead, is there some way I can tell the callback to be called less often
(say every second)? I suppose I could just stop the callback and create a
timer to start it again... or is there a better way?

I don't want to up the ulimit at this point - I just want to properly handle
this condition.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.schmorp.de/pipermail/libev/attachments/20080121/064d1859/attachment-0001.htm 

More information about the libev mailing list