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

Re: svn_stream_copy3() in svn_io.h

From: Greg Stein <gstein_at_gmail.com>
Date: Wed, 8 Apr 2009 05:04:08 +0200

On Wed, Apr 8, 2009 at 03:31, Edmund Wong <ed_at_kdtc.net> wrote:
> Greg Stein wrote:
>
>> Right. I added to the TODO for specifically that reason: the streams
>> may not get closed if an error occurs. In some scenarios, we want to
>> ensure that svn_stream_close() is *always* called on certain streams.
>> Their logic needs/wants to rely on the fact that the streams will
>> always be closed after calling svn_stream_copy3().
>>
>> Edmund: this should be a nice little bite-sized task to tweak that
>> function to ensure they're always closed.
>>
>
> I have been thinking about this task and if I may proverbially
> pick your brain (or anyone else's for that matter), even if
> an error arises, say cancel_func(cancel_baton)) chokes and
> errors, then SVN_ERR will return the error back to
> svn_stream_copy3 which then returns the error to the calling
> program, right?
>
> So just as long as I still capture the svn_error_t and still
> have the function flow get to the final return, all is well?
>
> Have I got the task correctly, for lack of a better word,
> diagnosed?

The error does need to be propagated back, yes. But those streams need
to be closed.

I believe you're going to end up with code something like:

  err = cancel_func(baton);
  if (err)
    {
      err = svn_error_compose_create(err, svn_stream_close(src));
      err = svn_error_compose_create(err, svn_stream_close(dst));
      return err;
    }

(note: the above isn't syntax perfect; just illustrative)

I don't recall how many SVN_ERR() uses are in that function. If a lot,
then you might end up with logic something like:

  err = do_something(...)
  if (err)
    goto err_cleanup;
...
  err_cleanup:
    err = svn_error_compse_create(err, ...

Propagating the error is correct. You nailed that one. But it is
possible that somebody will decide to ignore/discard the error as
"allowable". The program won't necessarily exit. Thus, the advertised
"will close" still needs to be met.

Cheers,
-g

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=1588729
Received on 2009-04-08 05:04:32 CEST

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.