[erlang-questions] file:sync

Matthew Sackman matthew@REDACTED
Wed Mar 7 13:20:08 CET 2007


Hi,

I've been seeing different performances of disk_log:sync under *nix and
win32 and have been tracing through the erlang code base to see where
it comes out. So, obviously it ends up in some C code, called via the
ports through file:sync.

So, for ./erts/emulator/drivers/unix/unix_efile.c

int
efile_fsync(Efile_error *errInfo, /* Where to return error codes. */
	    int fd)               /* File descriptor for file to sync. */
{
#ifdef NO_FSYNC
#ifdef VXWORKS
    return check_error(ioctl(fd, FIOSYNC, 0), errInfo); 
#else
  undefined fsync
#endif /* VXWORKS */
#else
    return check_error(fsync(fd), errInfo);
#endif /* NO_FSYNC */
}

ok - the important line being the last where fsync is actually called
which is in glibc unistd.h which is imported. Fine.

Then we have for ./erts/emulator/drivers/win32/win_efile.c

int
efile_fsync(errInfo, fd)
Efile_error* errInfo;		/* Where to return error codes. */
int fd;				/* File descriptor for file to sync. */
{
    return 1;
}

This appears to be a slightly troubling implementation and I see no
magic redefinition of 1 anywhere. Googling around, everyone seems to map
fsync to _commit on win32 and yet _commit appears no where in the erlang
source tree. The most telling example I can find is from
http://doxygen.postgresql.org/include_2port_2win32_8h-source.html

#define fsync(fd) _commit(fd)

So have I gone mad, or is this a lacking implementation of file:sync on
win32?

Cheers,

Matthew



More information about the erlang-questions mailing list