Problem in tevent_signal
simo
idra at samba.org
Sat Jan 28 14:47:49 MST 2012
On Sat, 2012-01-28 at 22:32 +0100, Volker Lendecke wrote:
> On Sat, Jan 28, 2012 at 04:29:53PM -0500, simo wrote:
> > 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().
>
> The fix I posted is almost what you propose I think.
Ah sorry I did not see the patch. Yeah it is close but by referncing
itself it becomes hard to read.
I was thinking something like this:
struct tevent_se_spy {
bool *was_freed;
};
static int tevent_se_spy_destructor(struct tevent_se_spy *s)
{
*s->was_freed = true;
}
then in tevent_common_check_signal()
struct tevent_se_spy *se_spy;
bool se_was_freed = false;
se_spy = talloc_zero(se, struct tevent_se_spy);
if (!se_spy) {
continue;
}
se_spy->was_freed = &se_was_freed;
talloc_set_destructor(se_spy, tevent_se_spy_destructor);
[...]
if (!se_was_freed && (se->sa_flags & SA_RESETHAND)) {
talloc_free(se);
}
To me the boolean is easier to read and understand, but either way would
work.
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