[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] svn_client_ctx_t callback fixes, mark 3

From: Walter Mundt <emage_at_spamcop.net>
Date: 2006-06-04 23:34:27 CEST

David James wrote:
>> (svn_swig_py_pool_set_owned_ref): New helper function to manage pool
>> "owned references."
>
> To quote the documentation: This function "replaces an 'owned
> reference' allocated in a pool from oldRef to newRef. If oldRef is
> non-NULL and present in the parent pool of proxy, it is removed."
>
> The replace operation in svn_swig_py_pool_set_owned_ref function is
> atomic and thread-safe, assuming that the caller is holding the Python
> global interpreter lock. (Is this a safe assumption to make?)

I actually don't think it necessarily is. This function and several
other helpers that are used in typemaps (most notably
svn_swig_MustGetPtr) get called either before or after the block of code
where the Python GIL is acquired in the generated code, but can execute
arbitrary Python code. (At least here/on my version of swig.) In the
case of proxy object getters and setters, the Python GIL is never
acquired at all.

While that seemed wrong to me, I decided not to worry about it for now,
since the bindings currently do this and work anyway. Another patch for
another day, assuming you don't pull another swig magic trick out of
your hat that says the GIL is already acquired before calling some of
these generated functions. (If you do that, then the code to
acquire/release the GIL is inserted redundantly in a number of places.)

> Oops. This should be "self.change_author". I fixed this before committing.

Sorry, forgot to fix this after the last patch!

> What do "obj0" and "arg1->$1_name" refer to? Why are these hacks
> necessary? It would be nice to follow up with a comment to explain
> what's going on here.

Sorry, I added this at the last minute and forgot to document it. obj0
is the Python proxy for the client context. arg1 is the actual client
context pointer. $1_name is a SWIG macro for the name of $input
(assuming 1 input), e.g. "log_msg_baton2". I needed access to both the
Python proxy object (for finding its parent pool) and the actual
previous value of the C field (for decrementing the pointed-to object's
refcount), and these were the only ways I could manage to get at both.
If you have less-hackish suggestions for either, they would be more than
welcome.

-Walter

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sun Jun 4 23:35:48 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.