Return-Path: X-Original-To: apmail-subversion-commits-archive@minotaur.apache.org Delivered-To: apmail-subversion-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D6382DBC5 for ; Fri, 17 May 2013 21:08:45 +0000 (UTC) Received: (qmail 51359 invoked by uid 500); 17 May 2013 21:08:46 -0000 Delivered-To: apmail-subversion-commits-archive@subversion.apache.org Received: (qmail 51259 invoked by uid 500); 17 May 2013 21:08:46 -0000 Mailing-List: contact commits-help@subversion.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@subversion.apache.org Delivered-To: mailing list commits@subversion.apache.org Received: (qmail 51252 invoked by uid 99); 17 May 2013 21:08:46 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 May 2013 21:08:46 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 May 2013 21:08:44 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id B96F923889E2; Fri, 17 May 2013 21:08:24 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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 Date: Fri, 17 May 2013 21:08:24 -0000 To: commits@subversion.apache.org From: rhuijben@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130517210824.B96F923889E2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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. */