create_conn_struct_tos() and connection re-use

Stefan Metzmacher metze at
Fri Jun 22 22:15:56 UTC 2018

Am 22.06.2018 um 23:56 schrieb Andrew Bartlett via samba-technical:
> On Fri, 2018-06-22 at 14:15 -0700, Jeremy Allison wrote:
>> On Sat, Jun 23, 2018 at 08:57:35AM +1200, Andrew Bartlett via samba-technical wrote:
>>> OK.  I recently got asked to make samba-tool ntacl sysvolreset faster. 
>>> (Folks do this once after every rsync to keep their sysvol permissions
>>> in line, so it is really important to make fast). 
>>> One thing that code did is call create_conn_struct() for every python
>>> function call, now replaced by create_conn_struct_tos(). 
>>> Assuming this repeated setup is part of what is making this so slow
>>> (I've not checked yet, that will be step 0), what is the right way to
>>> set up a connection only once for this use case?
>> Looking at the python wrappers:
>> Each call does:
>>        if (!PyArg_ParseTupleAndKeywords(args, kwargs, "si|z", discard_const_p(char *, kwnames),
>>                                          &fname, &security_info_wanted, &service)) {
>>                 TALLOC_FREE(frame);
>>                 return NULL;
>>         }
>>         conn = get_conn_tos(service);
>> so the char *service parameter can be different for
>> each call.
>> You'd have to create varients of the python wrappers that
>> guarantee a constant server name and hold the frame across
>> multiple calls.
> Well, I can't hold a talloc_stackframe() across different calls, that's
> the thing, we will need to return to python a connection object.  
> The idea is to have a call to set up a connection, and then make file
> operations in new function calls that pass in that connection.  How do
> I do that safely?

There's currently no way to do that, sorry.
I guess you need to create something better,
In python you need some kind of 'connection'.
Maybe you can take the lower level stuff.
and use a given talloc pointer instead of talloc_tos().
But it would be much better to just have some way
of setting up this stuff and the master copy is
make_connection_snum() that needs cleanup, so that
it's possible to create a vfs stack not depending on
SMB logic.

But this needs a lot of thinking to get right.
The upcoming impersonation support will further complicate
the event context, threadpool juggling.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the samba-technical mailing list