[Libevent-users] Bug in signal.c
Scott Lamb
slamb at slamb.org
Mon May 28 15:37:22 EDT 2007
On May 28, 2007, at 8:28 AM, Jesse Keller wrote:
> Just implemented libevent in a new program using the cool eventxx C++
> wrapper. Anyway, I decided to track down the event_base_free bug a
> little more. Here's the original bug and patch.
>
> http://monkeymail.org/archives/libevent-users/2006-April/000141.html
>
> Seems that we don't need to go through all that effort of fixing the
> symptom, it's just that the internal event between the signal handler
> and the dispatcher is never deleted.
>
> Here's the patch that fixes the problem for me (versus the 1.3b
> release)
>
>
> --- signal.c 2007-03-03 23:05:07.000000000 -0500
> +++ signal.c.new 2007-05-28 11:10:57.000000000 -0400
> @@ -143,6 +143,11 @@
> int evsignal;
>
> evsignal = EVENT_SIGNAL(ev);
> +
> + if (ev_signal_added) {
> + ev_signal_added = 0;
> + event_del(&ev_signal);
> + }
>
> return (sigaction(EVENT_SIGNAL(ev),(struct sigaction *)
> SIG_DFL,
> NULL));
> }
But ev_signal is for the pipe used to wake up on receipt of *any*
signal. Consider this code snippet:
signal_set(&ev1, SIGUSR1, signal_cb, NULL);
event_add(&ev1, NULL);
signal_set(&ev2, SIGUSR2, signal_cb, NULL);
event_add(&ev2, NULL);
event_del(&ev2);
raise(SIGUSR1);
event_dispatch(EVLOOP_ONCE);
without your change, the dispatch would return immediately. With your
change, it would wait until timeout.
--
Scott Lamb <http://www.slamb.org/>
More information about the Libevent-users
mailing list