Yee Keat Phuah | 3 Sep 09:49 2010

Stop listening on http server when accept() returns Too Many Open Files


I am using the http server part of libevent 2.0.6, and currently testing it under all sorts of situation. One of the situation I ran into is when there are too many connections, there might be "Too Many Open Files" returned from the accept() call, that is ok, but the problem is because in listener.c:listener_read_cb() function, there's no way I could intercept this error message, and maybe stop accepting new connections, what happen subsequently is that event_sock_warn just gets called thousands of time.

Is there a way that I can intercept this error and act accordingly? Probably stop listening for a while?

Thanks in advance.

Phuah Yee Keat