You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2013/05/17 23:08:24 UTC

svn commit: r1483993 - in /subversion/trunk/subversion: include/svn_io.h libsvn_ra_serf/commit.c libsvn_ra_serf/update.c libsvn_subr/io.c libsvn_subr/prompt.c

Author: rhuijben
Date: Fri May 17 21:08:24 2013
New Revision: 1483993

URL: http://svn.apache.org/r1483993
Log:
Create a new svn_io_file_flush() wrapper function around the apr variant and
use it to plug some error leaks.

This has the nice side effect to make users make a deliberate decision between
using svn_io_file_flush() and svn_io_file_flush_to_disk() (which more or less
wraps the recently added apr_file_sync())

* subversion/include/svn_io.h
  (svn_io_file_flush): New function.

* subversion/libsvn_ra_serf/commit.c
  (create_put_body): Update caller.

* subversion/libsvn_ra_serf/update.c
  (finish_report): Update caller.

* subversion/libsvn_subr/io.c
  (svn_io_file_flush): New function.

* subversion/libsvn_subr/prompt.c
  (terminal_puts): Update caller.

Modified:
    subversion/trunk/subversion/include/svn_io.h
    subversion/trunk/subversion/libsvn_ra_serf/commit.c
    subversion/trunk/subversion/libsvn_ra_serf/update.c
    subversion/trunk/subversion/libsvn_subr/io.c
    subversion/trunk/subversion/libsvn_subr/prompt.c

Modified: subversion/trunk/subversion/include/svn_io.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_io.h?rev=1483993&r1=1483992&r2=1483993&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_io.h (original)
+++ subversion/trunk/subversion/include/svn_io.h Fri May 17 21:08:24 2013
@@ -2073,6 +2073,14 @@ svn_io_file_write(apr_file_t *file,
                   apr_size_t *nbytes,
                   apr_pool_t *pool);
 
+/** Wrapper for apr_file_flush().
+ * @since New in 1.9
+ */
+svn_error_t *
+svn_io_file_flush(apr_file_t *file,
+                  apr_pool_t *scratch_pool);
+
+
 
 /** Wrapper for apr_file_write_full(). */
 svn_error_t *

Modified: subversion/trunk/subversion/libsvn_ra_serf/commit.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/commit.c?rev=1483993&r1=1483992&r2=1483993&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/commit.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/commit.c Fri May 17 21:08:24 2013
@@ -984,7 +984,7 @@ create_put_body(serf_bucket_t **body_bkt
    * check the buffer status; but serf will fall through and create a file
    * bucket for us on the buffered svndiff handle.
    */
-  apr_file_flush(ctx->svndiff);
+  SVN_ERR(svn_io_file_flush(ctx->svndiff, pool));
 #if APR_VERSION_AT_LEAST(1, 3, 0)
   apr_file_buffer_set(ctx->svndiff, NULL, 0);
 #endif

Modified: subversion/trunk/subversion/libsvn_ra_serf/update.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/update.c?rev=1483993&r1=1483992&r2=1483993&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/update.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/update.c Fri May 17 21:08:24 2013
@@ -2777,7 +2777,7 @@ finish_report(void *report_baton,
    * check the buffer status; but serf will fall through and create a file
    * bucket for us on the buffered svndiff handle.
    */
-  apr_file_flush(report->body_file);
+  SVN_ERR(svn_io_file_flush(report->body_file), iterpool);
 #if APR_VERSION_AT_LEAST(1, 3, 0)
   apr_file_buffer_set(report->body_file, NULL, 0);
 #endif

Modified: subversion/trunk/subversion/libsvn_subr/io.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/io.c?rev=1483993&r1=1483992&r2=1483993&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/io.c (original)
+++ subversion/trunk/subversion/libsvn_subr/io.c Fri May 17 21:08:24 2013
@@ -3408,6 +3408,16 @@ svn_io_file_write(apr_file_t *file, cons
      pool));
 }
 
+svn_error_t *
+svn_io_file_flush(apr_file_t *file,
+                  apr_pool_t *scratch_pool)
+{
+  return svn_error_trace(do_io_file_wrapper_cleanup(
+     file, apr_file_flush(file),
+     N_("Can't flush file '%s'"),
+     N_("Can't flush stream"),
+     scratch_pool));
+}
 
 svn_error_t *
 svn_io_file_write_full(apr_file_t *file, const void *buf,

Modified: subversion/trunk/subversion/libsvn_subr/prompt.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/prompt.c?rev=1483993&r1=1483992&r2=1483993&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/prompt.c (original)
+++ subversion/trunk/subversion/libsvn_subr/prompt.c Fri May 17 21:08:24 2013
@@ -236,7 +236,6 @@ terminal_puts(const char *string, termin
               apr_pool_t *pool)
 {
   svn_error_t *err;
-  apr_status_t status;
   const char *converted;
 
   err = svn_cmdline_cstring_from_utf8(&converted, string, pool);
@@ -255,13 +254,10 @@ terminal_puts(const char *string, termin
     }
 #endif
 
-  status = apr_file_write_full(terminal->outfd, converted,
-                               strlen(converted), NULL);
-  if (!status)
-    status = apr_file_flush(terminal->outfd);
-  if (status)
-    return svn_error_wrap_apr(status, _("Can't write to terminal"));
-  return SVN_NO_ERROR;
+  SVN_ERR(svn_io_file_write_full(terminal->outfd, converted,
+                                 strlen(converted), NULL, pool));
+
+  return svn_error_trace(svn_io_file_flush(terminal->outfd, pool));
 }
 
 /* These codes can be returned from terminal_getc instead of a character. */