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

svn_stream_copy3() in svn_io.h

From: Edmund Wong <ed_at_kdtc.net>
Date: Tue, 07 Apr 2009 19:15:10 +0800

Hi,

Again, reading svn_io.h, I came across a "TODO" for the
svn_stream_copy3() :

  * ### TODO: should close the streams ALWAYS, even on error exit

  Thinking that it might be my chance to do something for a
change, I looked into stream.c (this *is* the file, right?)
and came across the following:-

svn_error_t *svn_stream_copy3(svn_stream_t *from, svn_stream_t *to,
                               svn_cancel_func_t cancel_func,
                               void *cancel_baton,
                               apr_pool_t *scratch_pool)
{
   char *buf = apr_palloc(scratch_pool, SVN__STREAM_CHUNK_SIZE);

   /* Read and write chunks until we get a short read, indicating the
      end of the stream. (We can't get a short write without an
      associated error.) */
   while (1)
     {
       apr_size_t len = SVN__STREAM_CHUNK_SIZE;

       if (cancel_func)
         SVN_ERR(cancel_func(cancel_baton));

       SVN_ERR(svn_stream_read(from, buf, &len));
       if (len > 0)
         SVN_ERR(svn_stream_write(to, buf, &len));
       if (len != SVN__STREAM_CHUNK_SIZE)
         break;
     }

   return svn_error_compose_create(svn_stream_close(from),
                                   svn_stream_close(to));
}

Does this mean that since svn_stream_copy3() calls
svn_stream_close() on both from and to, both from
and to are closed after the return? (Though I'm not sure if
the resulting closure will result in an error.)

If it does mean so, shouldn't the TODO be 'removed'?

Thanks.

Edmund

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=1575869
Received on 2009-04-07 13:15:30 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.