[MacPorts] #16145: Erlang R12B-3 needs a patch for fsync problem

MacPorts noreply at macports.org
Thu Mar 24 08:58:38 PDT 2016


#16145: Erlang R12B-3 needs a patch for fsync problem
-----------------------------+------------------------
  Reporter:  jerry.jalava@…  |      Owner:  bfulgham@…
      Type:  defect          |     Status:  closed
  Priority:  Normal          |  Milestone:
 Component:  ports           |    Version:  1.6.0
Resolution:  fixed           |   Keywords:
      Port:  erlang          |
-----------------------------+------------------------
Changes (by ryandesign@…):

 * port:   => erlang


Old description:

> The following has been taken from the erlang-patches mailing list.
> (http://www.erlang.org/pipermail/erlang-patches/2008-July/000258.html)
> --------
>
> Dear OTP Team,
>
> traditionally, on UNIX systems the fsync() system call is used
> to flush any filesystem buffers to disk. The file::sync() function
> triggers a fsync() call in OTP R12B-3
>
> On Darwin (and Mac OS X) systems, the fsync() system call
> exists, but does not guarantee the writing to disk. The
> fcntl(F_FULLFSYNC) function call exists to achieve this.
> See
> http://developer.apple.com/documentation/Darwin/Reference/ManPages/man2/fsync.2.html
> and
> http://developer.apple.com/documentation/Darwin/Reference/ManPages/man2/fcntl.2.html
> for reference.
>
> The patch below adds some #ifdefs to figure out if it is
> compiled on a Darwin system and uses the fcntl() function
> instead of the fsync() function.
>
> Please note my poor understanding of how your build system
> actually detects the target host. My way of detecting Darwin
> was shamelessly ripped from elsewhere in the source tree
> and might be wrong in this case (although testing was successful).
> Please feel free to make any necessary changes in case you
> choose to integrate the patch.
>
> I'm working on the CouchDB project (yes, a database in Erlang),
> and we require a reliable file::sync()-behaviour for data consistency.
>
> Adding this to OTP would be highly appreciated.
>
> Cheers
> Jan & the CouchDB Team
> --
>
> --- erts/emulator/drivers/unix/unix_efile.c.orig        2008-07-17
> 20:44:23.000000000 +0200
> +++ erts/emulator/drivers/unix/unix_efile.c     2008-07-17
> 20:44:21.000000000 +0200
> @@ -44,6 +44,14 @@
>   #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>
> @@ -818,7 +826,11 @@
>     undefined fsync
>   #endif /* VXWORKS */
>   #else
> +#if defined(DARWIN) && defined(F_FULLFSYNC)
> +    return check_error(fcntl(fd, F_FULLFSYNC), errInfo);
> +#else
>       return check_error(fsync(fd), errInfo);
> +#endif /* DARWIN */
>   #endif /* NO_FSYNC */
>   }
>
> ------
>
> Until this hopefulle gets added to the OTP at some point it would be
> great to include it in Port.
>
> Regards,
> Jerry

New description:

 The following has been taken from the erlang-patches mailing list.
 (http://www.erlang.org/pipermail/erlang-patches/2008-July/000258.html)
 --------

 Dear OTP Team,

 traditionally, on UNIX systems the fsync() system call is used
 to flush any filesystem buffers to disk. The file::sync() function
 triggers a fsync() call in OTP R12B-3

 On Darwin (and Mac OS X) systems, the fsync() system call
 exists, but does not guarantee the writing to disk. The
 fcntl(F_FULLFSYNC) function call exists to achieve this.
 See
 http://developer.apple.com/documentation/Darwin/Reference/ManPages/man2/fsync.2.html
 and
 http://developer.apple.com/documentation/Darwin/Reference/ManPages/man2/fcntl.2.html
 for reference.

 The patch below adds some #ifdefs to figure out if it is
 compiled on a Darwin system and uses the fcntl() function
 instead of the fsync() function.

 Please note my poor understanding of how your build system
 actually detects the target host. My way of detecting Darwin
 was shamelessly ripped from elsewhere in the source tree
 and might be wrong in this case (although testing was successful).
 Please feel free to make any necessary changes in case you
 choose to integrate the patch.

 I'm working on the CouchDB project (yes, a database in Erlang),
 and we require a reliable file::sync()-behaviour for data consistency.

 Adding this to OTP would be highly appreciated.

 Cheers\\
 Jan & the CouchDB Team

 {{{
 --- erts/emulator/drivers/unix/unix_efile.c.orig        2008-07-17
 20:44:23.000000000 +0200
 +++ erts/emulator/drivers/unix/unix_efile.c     2008-07-17
 20:44:21.000000000 +0200
 @@ -44,6 +44,14 @@
   #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>
 @@ -818,7 +826,11 @@
     undefined fsync
   #endif /* VXWORKS */
   #else
 +#if defined(DARWIN) && defined(F_FULLFSYNC)
 +    return check_error(fcntl(fd, F_FULLFSYNC), errInfo);
 +#else
       return check_error(fsync(fd), errInfo);
 +#endif /* DARWIN */
   #endif /* NO_FSYNC */
   }
 }}}

 Until this hopefulle gets added to the OTP at some point it would be great
 to include it in Port.

 Regards,\\
 Jerry

--

-- 
Ticket URL: <https://trac.macports.org/ticket/16145#comment:9>
MacPorts <https://www.macports.org/>
Ports system for OS X


More information about the macports-tickets mailing list