aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2004-07-17 21:44:57 +0000
committerdrh <drh@noemail.net>2004-07-17 21:44:57 +0000
commitdd809b087f91fd906ba701da8487254eb16a8db0 (patch)
tree3ea26d84745a4621dff6b83e0ce6a687c636ca4c /src
parent4ebfef14e3e1e4ce666a53a36956a91bcc598af7 (diff)
downloadsqlite-dd809b087f91fd906ba701da8487254eb16a8db0.tar.gz
sqlite-dd809b087f91fd906ba701da8487254eb16a8db0.zip
Use the F_FULLFSYNC fctrl if it is available. Record the name of files
that are opened in the OsFile structure. (CVS 1799) FossilOrigin-Name: 1d30d0dd46c2bd12ce3f7dc06492f3e27ab6bcee
Diffstat (limited to 'src')
-rw-r--r--src/os_unix.c21
-rw-r--r--src/os_unix.h1
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 */