[PATCH] Allow talloc reparenting in a destructor.

Volker Lendecke Volker.Lendecke at SerNet.DE
Thu Mar 5 09:24:32 MST 2015


On Wed, Mar 04, 2015 at 01:28:53PM -0800, Jeremy Allison wrote:
> Here is a proposed addition to talloc (plus tests for it).
> 
> If a destructor returns failure (-1) when freeing a child, talloc
> reparents the child so the memory doesn't get lost.
> 
> Firstly it tries the owner of any reference, next the parent of the
> current object calling _talloc_free_children_internal(), and finally
> the null context in the last resort.
> 
> If a destructor reparents its own object, which can be a very
> desirable thing to do (a destructor can make a decision it isn't
> time to die yet, and as the parent may be going away it might
> want to move itself to longer-term storage) then this new parent
> gets overwritten by the existing reparenting logic.
> 
> This patch checks when freeing a child if it already reparented
> itself, and if it did then it doesn't overwrite the new parent.
> 
> Please review and push.

Pushed, but fails with

[2750/4333] Compiling lib/talloc/testsuite.c
cc1: warnings being treated as errors ../lib/talloc/testsuite.c: In function 'reparenting_destructor':
../lib/talloc/testsuite.c:991: error: value computed is not used
Waf: Leaving directory `/memdisk/vlendec/a/b24052/samba/bin'
Build failed:  -> task failed (err #1): 
        {task: cc testsuite.c -> testsuite_1.o}
make: *** [all] Error 1

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