diff options
author | drh <drh@noemail.net> | 2006-02-11 01:25:50 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2006-02-11 01:25:50 +0000 |
commit | ac530b1ab44b1703da039290cbcdd5cc0d3bb467 (patch) | |
tree | 02f28527124878f2373edfdaccc030fcb24bc341 /src/os_unix.c | |
parent | 78aecb72507785c8e2a0adb5bc2641b088f6d533 (diff) | |
download | sqlite-ac530b1ab44b1703da039290cbcdd5cc0d3bb467.tar.gz sqlite-ac530b1ab44b1703da039290cbcdd5cc0d3bb467.zip |
Add support and documentation for the fullfsync pragma. Also include
some other unrelated documentation updates. (CVS 3080)
FossilOrigin-Name: f2069d0bf3161591535e68b7389792e9cb7fe043
Diffstat (limited to 'src/os_unix.c')
-rw-r--r-- | src/os_unix.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index e33f0f7c5..b64f614d5 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -981,6 +981,17 @@ int sqlite3_fullsync_count = 0; # define fdatasync fsync #endif +/* +** Define HAVE_FULLFSYNC to 0 or 1 depending on whether or not +** the F_FULLFSYNC macro is defined. F_FULLFSYNC is currently +** only available on Mac OS X. But that could change. +*/ +#ifdef F_FULLFSYNC +# define HAVE_FULLFSYNC 1 +#else +# define HAVE_FULLFSYNC 0 +#endif + /* ** The fsync() system call does not work as advertised on many @@ -1012,7 +1023,7 @@ static int full_fsync(int fd, int fullSync, int dataOnly){ rc = SQLITE_OK; #else -#ifdef F_FULLFSYNC +#if HAVE_FULLFSYNC if( fullSync ){ rc = fcntl(fd, F_FULLFSYNC, 0); }else{ @@ -1057,10 +1068,16 @@ static int unixSync(OsFile *id, int dataOnly){ return SQLITE_IOERR; } if( pFile->dirfd>=0 ){ - TRACE2("DIRSYNC %-3d\n", pFile->dirfd); + TRACE4("DIRSYNC %-3d (have_fullfsync=%d fullsync=%d)\n", pFile->dirfd, + HAVE_FULLFSYNC, pFile->fullSync); #ifndef SQLITE_DISABLE_DIRSYNC - if( full_fsync(pFile->dirfd, pFile->fullSync, 0) ){ - /* We have received multiple reports of fsync() returning + /* The directory sync is only attempted if full_fsync is + ** turned off or unavailable. If a full_fsync occurred above, + ** then the directory sync is superfluous. + */ + if( (!HAVE_FULLFSYNC || !pFile->fullSync) && full_fsync(pFile->dirfd,0,0) ){ + /* + ** We have received multiple reports of fsync() returning ** errors when applied to directories on certain file systems. ** A failed directory sync is not a big deal. So it seems ** better to ignore the error. Ticket #1657 |