couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Lehnardt <...@apache.org>
Subject Re: Custom file driver for OS X and Windows Re: CouchDB 0.9 and 1.0
Date Thu, 17 Jul 2008 01:13:00 GMT

On Jul 2, 2008, at 19:01, Damien Katz wrote:

> So erlang still has some file driver troubles. The old issue of a  
> 2gig limit is long gone, however two other issues remain:
>
> Erlangs built-in file api for disk sync/flush doesn't work on all  
> platforms. The main two that I know where it doesn't work are  
> windows (at least it didn't when a looked over a year ago) and OS X  
> (perhaps other BSDs?). On OS X, the fix seems to be as simple as  
> passing the F_FULLFSYNC flag to fcntl. Without this disk sync, there  
> is no way CouchDB can safely store data. This means we either need  
> the Erlang folks to fix their drivers, or create our own file driver  
> for the problem platforms. Blech.

I'm not a C hacker and all but would this patch solve the issue on  
Darwin / Mac OS X?

I worked solely off documentation:
http://developer.apple.com/documentation/Darwin/Reference/ManPages/man2/fsync.2.html#/ 
/apple_ref/doc/man/2/fsync
http://developer.apple.com/documentation/Darwin/Reference/ManPages/man2/fcntl.2.html

The diff is against OTP R12B-3:

--- erts/emulator/drivers/unix/unix_efile.c	2008-07-17  
03:06:13.000000000 +0200
+++ erts/emulator/drivers/unix/unix_efile_new.c	2008-07-17  
03:06:57.000000000 +0200
@@ -44,11 +44,20 @@
  #endif
  #endif /* _OSE_ */

+#if defined(__APPLE__) && defined(__MACH__) && !defined(__DARWIN__)
+#define DARWIN 1
+#endif
+
+#ifdef DARWIN
+#include <fcntl.h>
+#endif /* DARWIN */
+
  #ifdef VXWORKS
  #include <ioLib.h>
  #include <dosFsLib.h>
  #include <nfsLib.h>
  #include <sys/stat.h>
+
  /*
  ** Not nice to include usrLib.h as MANY normal variable names get  
reported
  ** as shadowing globals, like 'i' for example.
@@ -818,7 +827,11 @@
    undefined fsync
  #endif /* VXWORKS */
  #else
+#ifdef DARWIN
+    return check_error(fcntl(fd, F_FULLFSYNC), errInfo);
+#else /* all other unix systems */
      return check_error(fsync(fd), errInfo);
+#endif /* DARWIN */
  #endif /* NO_FSYNC */
  }

If that looks okay, I'll forward it to the erlang-patches mailing list  
for inclusion.

Cheers
Jan
--

Mime
View raw message