problem about talloc with multi-threads
Jeremy Allison
jra at samba.org
Mon Aug 6 17:53:31 UTC 2018
On Fri, Aug 03, 2018 at 12:06:00PM +0800, ssdl.566 via samba-technical wrote:
> Hi all:
> i want to know how to use talloc with multi-threads.
> we need to access the same memory context , in multi threads,
You can't do that unless you use external locks to mediate.
talloc is *NOT* MT-safe internally.
> i want to ask what is the right way to use talloc in multi-threads.
You can use separate contexts from separate threads, so long
as they are individual top-level contexts.
Look at the function test_pthread_talloc_passing() in
lib/talloc/testsuite.c for an example of this.
Jeremy.
More information about the samba-technical
mailing list