svn commit: samba r18587 - in branches/SAMBA_4_0/source/libnet: .

tridge at tridge at
Sat Sep 16 20:37:11 GMT 2006


 > How did that introduce a memory leak ? Should libnet ctx as a parent not
 > depend on any other ?

The way it was used currently in the command line tools there is no
leak. The problem would come if libnet was called from smbd. In that
case the libnet context would be a top level context, and not a child
of the event context. It is really important that everything in smbd
be a child of the event context, otherwise calls like
event_context_find() won't work (which is called from things like the
winreg code), and it also makes it very tricky to track memory. 

It would also break the async code, as we'd end up with multiple event
contexts in the one process. That would mean that something waiting on
the 2nd event context will prevent events happening on the first

Ideally in smbd there would never be any talloc() on the NULL context
except the top level event context. In practice we can't quite reach
that, as some of the registration functions for modules need to
allocate memory and have no way to get the top level event context or
any other context as an argument. In that case we use

btw, that's why I said 'potential memory leak' in my commit message. I
don't think libnet was actually leaking anything, but I ran across
that talloc() on the NULL context while looking for other possible
leaks, and thought it was better to plug that one now, to prevent
future leaks when the libnet init code is called with an existing
event context.

sorry about the terse commit message - I should have explained more
clearly :)

Cheers, Tridge

More information about the samba-technical mailing list