[zeromq-dev] Even more fun with accept
sophacles at gmail.com
Wed Apr 29 19:31:20 CEST 2009
I would suggest a twofold approach. First off, the process should know its
maxfd value (in linux its a call to getrlimit, but i can't remember if that
is posix compliant). If the number of open sockets is at maxfd, try to
setrlimit maxfd to a higher number. As long as the soft limit is not set to
the hard limit, this will work.
Second, once at the hard limit for maxfd don't try to accept until open fds
is less than maxfd.
In Linux and the BSD maxfd is a kernel parameter that can be tweaked
somewhat at runtime, and somewhat at compile time, so there is a necessary
component of sysadmin cooperation.
I really don't know if the above approach will work or not, just that it is
what I would try first.
On Wed, Apr 29, 2009 at 11:27 AM, Martin Sustrik <sustrik at fastmq.com> wrote:
> I was just told that when EMFILE or ENFILE error (the socket limit is
> exceeded) is returned from accept the connection isn't purged from the
> listening queue.
> The consequence is that polling on the listening socket signalises that
> there's a pending connection, however, there's no way to accept it
> unless some sockets are closed in the meantime.
> Such behaviour results in a busy loop desperately trying to accept the
> connection, ultimately getting the CPU load to 100%.
> Any tips how to solve the problem?
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the zeromq-dev