You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Chia-liang Kao <cl...@clkao.org> on 2005/03/01 08:59:27 UTC
abort_edit in perl and python
Hi,
a delta_editor implementation in perl or python increase refcnt for the baton
returned by {add,open}_{file,directory}, and decreased in close. If the driver
calls abort_edit at some point, those batons are leaked. Actually even worse,
the editor baton (which is the instance of the editor object) is leaked, because
its refcnt is increased too for every add/open, I'm not sure if this is
neccessary. And from the svn_delta.h we can't call close_* after abort_edit for
clearing those refcnts:
Moreover, once an editing
function returns an error, the edit is dead; the only further
operation which may be called on the editor is abort_edit.
So my plan for rescuing the batons are to make the baton refcnt held by the
respective file/dir pool. Or do we have a better way to make abort_edit more
graceful in this case?
Cheers,
CLK
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: abort_edit in perl and python
Posted by John Peacock <jp...@rowman.com>.
Chia-liang Kao wrote:
> *nod* because the batons are whatever the editor returns. Mostly they're
> SV for me and can't have DESTROY :)
>
It should be sufficient to rebless the baton into a class which _does_ support a
DESTROY method (and empty subclass with only the DESTROY method).
John
--
John Peacock
Director of Information Research and Technology
Rowman & Littlefield Publishing Group
4720 Boston Way
Lanham, MD 20706
301-459-3366 x.5010
fax 301-429-5747
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: abort_edit in perl and python
Posted by Chia-liang Kao <cl...@clkao.org>.
On Tue, Mar 01, 2005 at 07:47:22AM -0500, John Peacock wrote:
> I was saying that the DESTROY on the *delta_editor* batons should decrement
> the refcnt on the *editor* object. If the delta_editor batons don't
> actually contain a reference to the editor object, then indeed the editor
> object should not be incremented in the first place.
*nod* because the batons are whatever the editor returns. Mostly they're
SV for me and can't have DESTROY :)
Cheers,
CLK
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: abort_edit in perl and python
Posted by John Peacock <jp...@rowman.com>.
Chia-liang Kao wrote:
> Three batons with a refcnt of 1, since they need to be held for
> apply_textdelta or child directories.
OK, that makes more sense. Do these batons have a DESTROY method? I can't look
at the code at the moment (got to go shovel the walk and then keep the kids busy
until school starts two hours late for a couple inches of snow). <ARGHHH>
>
> No, there's currently no such list maintained in the editor baton.
That's a pity, but not unsurmountable.
>
>
>>If there is a DESTROY for each object involved, this should also unwind the
>>editor baton refcnt.
>>
>
>
> huh? it's because the svn/perl bit holds the refcnt so the editor object is
> not freed and thus DESTROY is not called.
I was saying that the DESTROY on the *delta_editor* batons should decrement the
refcnt on the *editor* object. If the delta_editor batons don't actually
contain a reference to the editor object, then indeed the editor object should
not be incremented in the first place.
> It's not like blowing away their memory address. There's a util function
> in libsvn_swig_perl to make a pool decrease refcnt of an SV upon pool
> cleanup.
That makes me much happier, but it is still going outside of the Perl garbage
cleanup. I think it is preferable to have the batons clean up themselves if at
all possible.
John
--
John Peacock
Director of Information Research and Technology
Rowman & Littlefield Publishing Group
4720 Boston Way
Lanham, MD 20706
301-459-3366 x.5010
fax 301-429-5747
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: abort_edit in perl and python
Posted by Chia-liang Kao <cl...@clkao.org>.
On Tue, Mar 01, 2005 at 07:15:56AM -0500, John Peacock wrote:
> Without looking at the code (and speaking only to the way Perl works), this
> seems a little odd to me. Normally, the refcnt is incremented when more
> than one reference to the /same/ object exists. So if the delta_editor has
> three files to add, are you saying the same baton is used and has a refcnt
> of 3, or are there three batons with a refcnt of 1?
Three batons with a refcnt of 1, since they need to be held for
apply_textdelta or child directories.
> Does the abort_edit have access to the list of open batons? If so, why
> can't it perform the decrement? Isn't there DESTROY method for the objects
> in question, which will decrement references as the object goes out of
> scope?
No, there's currently no such list maintained in the editor baton.
> If there is a DESTROY for each object involved, this should also unwind the
> editor baton refcnt.
>
huh? it's because the svn/perl bit holds the refcnt so the editor object is
not freed and thus DESTROY is not called.
> >So my plan for rescuing the batons are to make the baton refcnt held by the
> >respective file/dir pool. Or do we have a better way to make abort_edit
> >more
> >graceful in this case?
>
> This is a great evil (hiding leaking scalars by blowing away their memory
> address). It would be much better to use the normal cleanup routines and
> have the object deallocate themselves when they go out of scope.
It's not like blowing away their memory address. There's a util function
in libsvn_swig_perl to make a pool decrease refcnt of an SV upon pool
cleanup.
Cheers,
CLK
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: abort_edit in perl and python
Posted by John Peacock <jp...@rowman.com>.
Chia-liang Kao wrote:
> a delta_editor implementation in perl or python increase refcnt for the baton
> returned by {add,open}_{file,directory}, and decreased in close.
Without looking at the code (and speaking only to the way Perl works), this
seems a little odd to me. Normally, the refcnt is incremented when more than
one reference to the /same/ object exists. So if the delta_editor has three
files to add, are you saying the same baton is used and has a refcnt of 3, or
are there three batons with a refcnt of 1?
> If the driver
> calls abort_edit at some point, those batons are leaked.
Does the abort_edit have access to the list of open batons? If so, why can't it
perform the decrement? Isn't there DESTROY method for the objects in question,
which will decrement references as the object goes out of scope?
> Actually even worse,
> the editor baton (which is the instance of the editor object) is leaked, because
> its refcnt is increased too for every add/open, I'm not sure if this is
> neccessary.
If there is a DESTROY for each object involved, this should also unwind the
editor baton refcnt.
> So my plan for rescuing the batons are to make the baton refcnt held by the
> respective file/dir pool. Or do we have a better way to make abort_edit more
> graceful in this case?
This is a great evil (hiding leaking scalars by blowing away their memory
address). It would be much better to use the normal cleanup routines and have
the object deallocate themselves when they go out of scope.
I'll try and look at the code and see if there is anything I can suggest (thus
making this less a drive-by suggestion). ;-)
John
--
John Peacock
Director of Information Research and Technology
Rowman & Littlefield Publishing Group
4720 Boston Way
Lanham, MD 20706
301-459-3366 x.5010
fax 301-429-5747
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org