Problem in tevent_signal

simo idra at samba.org
Sat Jan 28 14:29:53 MST 2012


On Sat, 2012-01-28 at 21:13 +0100, Volker Lendecke wrote: 
> Hi!
> 
> Destroying a tevent_signal event from within its handler
> isn't supported right now. See the following code sequence
> from tevent_signal.c:
> 
>         se->handler(ev, se, i, count, NULL, se->private_data);
> #ifdef SA_RESETHAND
>         if (se->sa_flags & SA_RESETHAND) {
>                 talloc_free(se);
>         }
> #endif
> 
> The signal handler might be gone after it was executed.
> 
> The trick used in tevent_timed is probably not really
> appropriate, we might run the same event more than once.
> 
> Working on it, maybe someone else has a bright idea how to
> solve this.
> 
> Volker
> 

I way to handle it is obvioulsy to copy se->sa_flags on the stack, and
secondly to add a destructor before calling se->handler();
The destructor would use another pointer on the stack to set a spy.
If that spy is set then the se has already been freed and nothing needs
to be done, otherwise it is safe to talloc_free().

Simo.

-- 
Simo Sorce
Samba Team GPL Compliance Officer <simo at samba.org>
Principal Software Engineer at Red Hat, Inc. <simo at redhat.com>



More information about the samba-technical mailing list