[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] Stop listening on http server when accept() returns Too Many Open Files



On Mon, Sep 20, 2010 at 12:50 PM, Simon Perreault
<simon.perreault@xxxxxxxxxxx> wrote:
> Thanks a lot for your reply!
>
> On 2010-09-20 12:29, Nick Mathewson wrote:
>> One possibility is that, when a non-retriable error occurs, the
>> callback is invoked with fd set to -1, and errno (LastSocketError) set
>> to the appropriate error.  This behavior would break programs that
>> don't expect listeners to ever call the listener callback with a bad
>> fd, so it would have to be off by default, and enabled via an
>> LEV_OPT_* option.
>>
>> Another possibility is to allow code to register a separate error
>> callback for each listener that would get invoked when an error
>> occurred.  This seems a little cleaner to me.
>
> I'd be fine with both, but I would also prefer the second option. A
> separate callback for errors is how the rest of libevent already works.
>
> Would the attached patch work?

Looks okay to me.   Probably, you'd want to rename "ecb" to "errorcb"
or something; we don't use "ecb" to mean "error callback" anywhere
else.

Is there any way to write a unit test for this?  I don't see a good
one beyond passing in a bogus fd to provoke an ENOTSOCK or something
like that, which is not the exact situation we're facing here, but
which at least would make sure the callback is getting run properly.
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.