Author: svn-role Date: Tue Mar 29 04:01:20 2022 New Revision: 1899341 URL: http://svn.apache.org/viewvc?rev=1899341&view=rev Log: Merge r1883355 from trunk:
* r1883355 Use the APR-1.4+ API for flushing file contents to disk. Justification: Reduce code duplication between APR and SVN. Votes: +1: brane, jun66j5, markphip Modified: subversion/branches/1.14.x/ (props changed) subversion/branches/1.14.x/STATUS subversion/branches/1.14.x/subversion/libsvn_subr/io.c Propchange: subversion/branches/1.14.x/ ------------------------------------------------------------------------------ Merged /subversion/trunk:r1883355 Modified: subversion/branches/1.14.x/STATUS URL: http://svn.apache.org/viewvc/subversion/branches/1.14.x/STATUS?rev=1899341&r1=1899340&r2=1899341&view=diff ============================================================================== --- subversion/branches/1.14.x/STATUS (original) +++ subversion/branches/1.14.x/STATUS Tue Mar 29 04:01:20 2022 @@ -79,13 +79,6 @@ Approved changes: Votes: +1: jamessan, stsp - * r1883355 - Use the APR-1.4+ API for flushing file contents to disk. - Justification: - Reduce code duplication between APR and SVN. - Votes: - +1: brane, jun66j5, markphip - * r1881534 Fix issue #4864 "build/ac-macros/macosx.m4: workaround AC_RUN_IFELSE" Justification: Modified: subversion/branches/1.14.x/subversion/libsvn_subr/io.c URL: http://svn.apache.org/viewvc/subversion/branches/1.14.x/subversion/libsvn_subr/io.c?rev=1899341&r1=1899340&r2=1899341&view=diff ============================================================================== --- subversion/branches/1.14.x/subversion/libsvn_subr/io.c (original) +++ subversion/branches/1.14.x/subversion/libsvn_subr/io.c Tue Mar 29 04:01:20 2022 @@ -2703,7 +2703,6 @@ svn_io__file_lock_autocreate(const char svn_error_t *svn_io_file_flush_to_disk(apr_file_t *file, apr_pool_t *pool) { - apr_os_file_t filehand; const char *fname; apr_status_t apr_err; @@ -2713,49 +2712,21 @@ svn_error_t *svn_io_file_flush_to_disk(a if (apr_err) return svn_error_wrap_apr(apr_err, _("Can't get file name")); - /* ### In apr 1.4+ we could delegate most of this function to - apr_file_sync(). The only major difference is that this doesn't - contain the retry loop for EINTR on linux. */ - - /* First make sure that any user-space buffered data is flushed. */ - SVN_ERR(svn_io_file_flush(file, pool)); - - apr_os_file_get(&filehand, file); - - /* Call the operating system specific function to actually force the - data to disk. */ - { -#ifdef WIN32 - - if (! FlushFileBuffers(filehand)) - return svn_error_wrap_apr(apr_get_os_error(), - _("Can't flush file '%s' to disk"), - try_utf8_from_internal_style(fname, pool)); - -#else - int rv; - - do { -#ifdef F_FULLFSYNC - rv = fcntl(filehand, F_FULLFSYNC, 0); -#else - rv = fsync(filehand); -#endif - } while (rv == -1 && APR_STATUS_IS_EINTR(apr_get_os_error())); - - /* If the file is in a memory filesystem, fsync() may return - EINVAL. Presumably the user knows the risks, and we can just - ignore the error. */ - if (rv == -1 && APR_STATUS_IS_EINVAL(apr_get_os_error())) - return SVN_NO_ERROR; - - if (rv == -1) - return svn_error_wrap_apr(apr_get_os_error(), - _("Can't flush file '%s' to disk"), - try_utf8_from_internal_style(fname, pool)); + do { + apr_err = apr_file_datasync(file); + } while(APR_STATUS_IS_EINTR(apr_err)); + + /* If the file is in a memory filesystem, fsync() may return + EINVAL. Presumably the user knows the risks, and we can just + ignore the error. */ + if (APR_STATUS_IS_EINVAL(apr_err)) + return SVN_NO_ERROR; + + if (apr_err) + return svn_error_wrap_apr(apr_err, + _("Can't flush file '%s' to disk"), + try_utf8_from_internal_style(fname, pool)); -#endif - } return SVN_NO_ERROR; }