create_conn_struct_tos() and connection re-use

Andrew Bartlett abartlet at samba.org
Fri Jun 22 20:57:35 UTC 2018


On Fri, 2018-06-22 at 09:34 -0700, Jeremy Allison via samba-technical
wrote:
> On Fri, Jun 22, 2018 at 07:36:38AM +0200, Stefan Metzmacher via samba-technical wrote:
> > Am 22.06.2018 um 07:25 schrieb Andrew Bartlett via samba-technical:
> > > 
> > > Why do we have functions like create_conn_struct_tos() then?
> > 
> > This is a special case! The code we had before was much worse
> > it created connection_struct which did sometime chdir and forgot to
> > chdir back and call VFS_DISCONNECT when done.
> > 
> > create_conn_struct_[cwd]_tos() is now only usable in one code block
> > that starts with frame = talloc_stackframe() and ends with
> > TALLOC_FREE(frame). This implements a restriction similar to
> > become_root()/unbecome_root() which always be used as pair
> > wrapping a specific shortterm section.
> > 
> > It's intended that the caller only have a change to control the lifetime
> > of the connection_struct by using this pattern and hopefully don't
> > find a ways to skip the destructor from being called.
> 
> Yes. I wrote the original (horrible) create_conn_struct() code
> and Metze's changes are a *significant* improvement on that.
> 
> The original idea as Metze says was to create a temporary
> conn struct valid only within a call stack to allow functions
> to be called from the msdfs code.
> 
> It's much clearer using a talloc_tos() context.

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?

Thanks,

Andrew Bartlett
-- 
Andrew Bartlett                       http://samba.org/~abartlet/
Authentication Developer, Samba Team  http://samba.org
Samba Developer, Catalyst IT          http://catalyst.net.nz/services/samba




More information about the samba-technical mailing list