Problem in tevent_signal

Volker Lendecke Volker.Lendecke at SerNet.DE
Sat Jan 28 17:20:30 MST 2012


On Sat, Jan 28, 2012 at 04:47:49PM -0500, simo wrote:
> 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.

I had that first as well. But then I had another
if-statement that guarded the talloc_free(exists). So I
added the *myself pointer to the structure to null it out.
This then led to the boolean go away.

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de


More information about the samba-technical mailing list