[Libevent-users] [PATCH] signal.c, evsignal.h: properly save/restore previous signal handlers and fix memory stomp

Scott Lamb slamb at slamb.org
Fri Nov 9 19:38:43 EST 2007


Christopher Layne wrote:
>>> -	if (!base->sig.ev_signal_added) {
>>> -		base->sig.ev_signal_added = 1;
>>> -		event_add(&base->sig.ev_signal, NULL);
>>> +	if (!sig->ev_signal_added) {
>>> +		sig->ev_signal_added = 1;
>>> +		event_add(&sig->ev_signal, NULL);
>>> 	}
>> There's a bug here (that predates your change): this code should handle 
>> event_add() failure. (E.g., epoll_ctl() returning ENOMEM.)
> 
> Fix in same, or sweep up in a later patch? How many other places are
> there where we're not currently checking the return value of
> event_add()? If there are more than this, we might as well just do it
> separately.
> 
> -cl

Looks like there are a number of others:

* evsignal_cb <- evsignal_add() should probably be using EV_PERSIST so 
this call is unnecessary

* bufferevent_read_cb
* bufferevent_read_pressure_cb
* bufferevent_write_cb
* bufferevent_write
* evdns_add_server_port
* evdns_server_request_respond
* evhttp_add_event
* evhttp_connection_start_detectclose
* evhttp_bind_socket

Most look straightforward to fix, but I'm not sure how the callbacks 
should indicate error.

There are also several unchecked event_del() calls, but I think it's 
safe to assume those will fail only on logic error.


More information about the Libevent-users mailing list