[SCM] Samba Shared Repository - branch master updated
Jeremy Allison
jra at samba.org
Wed Oct 19 16:19:56 MDT 2011
On Wed, Oct 19, 2011 at 03:29:54PM +0200, Stefan (metze) Metzmacher wrote:
> Am 18.10.2011 18:52, schrieb Jeremy Allison:
> >
> > Being more constructive :-).
> >
> > talloc_reference() is only used inside gensec_start.c, so
> > we only have a small piece of code to fix (and all the
> > callers of course :-).
> >
> > I'd be willing to work on this if you agree.
>
> As a long term goal I think we should avoid talloc_reference()
> and just let the caller to keep stuff arround for the lifetime
> of the created object (or async _send()/_recv() function function pair,
> all tevent_req based functions I know about follow that rule).
> As the caller is the one should now about the lifetimes of complex
> structures.
> For simple things like strings we should just copy.
>
> Or we should have explicit donations of objects like here:
>
> NTSTATUS wrepl_socket_donate_stream(struct wrepl_socket *wrepl_socket,
> struct tstream_context **stream)
> {
> if (wrepl_socket->stream) {
> return NT_STATUS_CONNECTION_ACTIVE;
> }
>
> wrepl_socket->stream = talloc_move(wrepl_socket, stream);
> return NT_STATUS_OK;
> }
Yes, this seems to me to be the right way to do things. For
shallow objects like strings just copy, for deeper structures
have XX_donate()/XX_retrieve() functions that pass ownership
to/from the library.
Jeremy.
More information about the samba-technical
mailing list