a little change in _send functions of libnet
Rafal Szczesniak
mimir at samba.org
Sun Dec 17 23:03:03 GMT 2006
On Sun, Dec 17, 2006 at 11:32:34PM +0100, Stefan (metze) Metzmacher wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi Rafal,
>
> > I'm thinking about changing _send functions so that they don't
> > take TALLOC_CTX argument. This means the composite context would
> > be based on libnet_context from the very beginning (right in
> > composite_create call). TALLOC_CTX would in such case be used
> > in _recv calls, for transferring the libnet function results.
>
> yes, it should be used in the _recv call for transferring the results,
> but also in the _send() call passed to composite_create()
>
> > This could simplify the code a bit, and make all memory allocation
> > depend on single libnet_context.
>
> I don't see how this will simply the code, if we pass libnet_ctx to
> composite_create()
It does not simplify calling composite_create() itself, it simplifies
the _send function call because it has one parameter less to provide.
> I think the rule should be to pass the callers mem_ctx to
> composite_create() then allocate the calls private state under the
> composite_context and then all subrequests on the private_state.
>
> then the recv() call transferrs results to the given mem_ctx
> and calls talloc_free(composite_context)
>
> then only the results are left on the callers mem_ctx and the rest is
> free'ed.
Clear. Still, the same can happen if composite context is a child of
libnet_context.
> I don't think that's a good idea, because if the composite_context
> is a child of a given memory then the request will be removed with a
> talloc_free() on the parent context too, with out an explicit
> talloc_free() on the request composite_context.
That's right. That's one of the reasons why I'd prefer it to be allocated
on libnet_context.
> I know we do current what you propose in some other client libs,
> but I'm not sure if that's good there too...
So, to summarise, you'd like to have TALLOC_CTX passed to the _send
functions, to let them allocate their composite_context as it's child.
Correct ?
cheers,
--
Rafal Szczesniak
Samba Team member http://www.samba.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.samba.org/archive/samba-technical/attachments/20061218/effec1ef/attachment.bin
More information about the samba-technical
mailing list