diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/os_unix.c | 21 | ||||
-rw-r--r-- | src/os_unix.h | 1 |
2 files changed, 20 insertions, 2 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index d6dede920..7bd9ded3f 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -655,6 +655,22 @@ int sqlite3OsSeek(OsFile *id, off_t offset){ } /* +** The fsync() system call does not work as advertised on many +** unix systems. The following procedure is an attempt to make +** it work better. +*/ +static int full_fsync(int fd){ + int rc; +#ifdef F_FULLFSYNC + rc = fcntl(fd, F_FULLFSYNC, 0); + if( rc ) rc = fsync(fd); +#else + rc = fsync(fd); +#endif + return rc; +} + +/* ** Make sure all writes to a particular file are committed to disk. ** ** Under Unix, also make sure that the directory entry for the file @@ -669,12 +685,12 @@ int sqlite3OsSync(OsFile *id){ assert( id->isOpen ); SimulateIOError(SQLITE_IOERR); TRACE2("SYNC %-3d\n", id->h); - if( fsync(id->h) ){ + if( full_fsync(id->h) ){ return SQLITE_IOERR; } if( id->dirfd>=0 ){ TRACE2("DIRSYNC %-3d\n", id->dirfd); - fsync(id->dirfd); + full_fsync(id->dirfd); close(id->dirfd); /* Only need to sync once, so close the directory */ id->dirfd = -1; /* when we are done. */ } @@ -1057,6 +1073,7 @@ int sqlite3OsUnlock(OsFile *id, int locktype){ */ int sqlite3OsClose(OsFile *id){ if( !id->isOpen ) return SQLITE_OK; + id->zFilename = 0; sqlite3OsUnlock(id, NO_LOCK); if( id->dirfd>=0 ) close(id->dirfd); id->dirfd = -1; diff --git a/src/os_unix.h b/src/os_unix.h index ae16a9ac6..9e11e4c92 100644 --- a/src/os_unix.h +++ b/src/os_unix.h @@ -65,6 +65,7 @@ struct OsFile { struct openCnt *pOpen; /* Info about all open fd's on this inode */ struct lockInfo *pLock; /* Info about locks on this inode */ int h; /* The file descriptor */ + const char *zFilename; /* Name passed to open() */ unsigned char locktype; /* The type of lock held on this fd */ unsigned char isOpen; /* True if needs to be closed */ int dirfd; /* File descriptor for the directory */ |