You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2015/05/28 17:23:30 UTC
svn commit: r1682259 - in /subversion/trunk/subversion:
include/private/svn_dep_compat.h libsvn_fs_fs/util.c libsvn_subr/io.c
Author: stefan2
Date: Thu May 28 15:23:30 2015
New Revision: 1682259
URL: http://svn.apache.org/r1682259
Log:
Fix our usage of fsync usage on non-Linux POSIX platforms.
They all share the "directory contains the file name" property.
* subversion/include/private/svn_dep_compat.h
(SVN_ON_POSIX): New define.
* subversion/libsvn_fs_fs/util.c
(svn_fs_fs__move_into_place): Always sync the parent directory when
we are on POSIX - not just for Linux.
* subversion/libsvn_subr/io.c
(svn_io_write_atomic): Same.
Modified:
subversion/trunk/subversion/include/private/svn_dep_compat.h
subversion/trunk/subversion/libsvn_fs_fs/util.c
subversion/trunk/subversion/libsvn_subr/io.c
Modified: subversion/trunk/subversion/include/private/svn_dep_compat.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_dep_compat.h?rev=1682259&r1=1682258&r2=1682259&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_dep_compat.h (original)
+++ subversion/trunk/subversion/include/private/svn_dep_compat.h Thu May 28 15:23:30 2015
@@ -75,6 +75,31 @@ extern "C" {
#endif
/**
+ * Indicate whether we are running on a POSIX platform. This has
+ * implications on the way e.g. fsync() works.
+ *
+ * For details on this check, see
+ * http://nadeausoftware.com/articles/2012/01/c_c_tip_how_use_compiler_predefined_macros_detect_operating_system#POSIX
+ *
+ * @since New in 1.10.
+ */
+#ifndef SVN_ON_POSIX
+#if !defined(_WIN32) \
+ && ( defined(__unix__) \
+ || defined(__unix) \
+ || (defined(__APPLE__) && defined(__MACH__))) /* UNIX-style OS? */
+# include <unistd.h>
+# if defined(_POSIX_VERSION)
+# define SVN_ON_POSIX 1
+# else
+# define SVN_ON_POSIX 0
+# endif
+#else
+# define SVN_ON_POSIX 0
+#endif
+#endif
+
+/**
* APR keeps a few interesting defines hidden away in its private
* headers apr_arch_file_io.h, so we redefined them here.
*
Modified: subversion/trunk/subversion/libsvn_fs_fs/util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/util.c?rev=1682259&r1=1682258&r2=1682259&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/util.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/util.c Thu May 28 15:23:30 2015
@@ -665,11 +665,10 @@ svn_fs_fs__move_into_place(const char *o
if (err)
return svn_error_trace(err);
-#ifdef __linux__
+#if SVN_ON_POSIX
{
- /* Linux has the unusual feature that fsync() on a file is not
- enough to ensure that a file's directory entries have been
- flushed to disk; you have to fsync the directory as well.
+ /* On POSIX, the file name is stored in the file's directory entry.
+ Hence, we need to fsync() that directory as well.
On other operating systems, we'd only be asking for trouble
by trying to open and fsync a directory. */
const char *dirname;
Modified: subversion/trunk/subversion/libsvn_subr/io.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/io.c?rev=1682259&r1=1682258&r2=1682259&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/io.c (original)
+++ subversion/trunk/subversion/libsvn_subr/io.c Thu May 28 15:23:30 2015
@@ -3878,11 +3878,10 @@ svn_io_write_atomic(const char *final_pa
scratch_pool));
}
-#ifdef __linux__
+#if SVN_ON_POSIX
{
- /* Linux has the unusual feature that fsync() on a file is not
- enough to ensure that a file's directory entries have been
- flushed to disk; you have to fsync the directory as well.
+ /* On POSIX, the file name is stored in the file's directory entry.
+ Hence, we need to fsync() that directory as well.
On other operating systems, we'd only be asking for trouble
by trying to open and fsync a directory. */
apr_file_t *file;