aboutsummaryrefslogtreecommitdiff
path: root/src/os_unix.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2010-05-20 23:51:06 +0000
committerdrh <drh@noemail.net>2010-05-20 23:51:06 +0000
commit286a28849332e8e32e711fe4fd0c49936978a839 (patch)
treea29adbe424bbeaa857181ce2df1a5fde7ecab940 /src/os_unix.c
parent7e263728f2af62e2eca639c1a7bd0e2985295c10 (diff)
downloadsqlite-286a28849332e8e32e711fe4fd0c49936978a839.tar.gz
sqlite-286a28849332e8e32e711fe4fd0c49936978a839.zip
Add a new xShmBarrier method to the VFS - a shared-memory fence operation.
Implement the same in both unix and win32. Use it to make the WAL subsystem more robust. FossilOrigin-Name: 1bd011c9fed5ef29fb616b4d0a52df3b82221b1f
Diffstat (limited to 'src/os_unix.c')
-rw-r--r--src/os_unix.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index ecdd261d2..0a302a455 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -3883,12 +3883,31 @@ static int unixShmLock(
return rc;
}
+/*
+** Implement a memory barrier or memory fence on shared memory.
+**
+** All loads and stores begun before the barrier must complete before
+** any load or store begun after the barrier.
+*/
+static void unixShmBarrier(
+ sqlite3_file *fd /* Database file holding the shared memory */
+){
+#ifdef __GNUC__
+ __sync_synchronize();
+#else
+ unixMutexEnter();
+ unixMutexLeave();
+#endif
+}
+
+
#else
# define unixShmOpen 0
# define unixShmSize 0
# define unixShmGet 0
# define unixShmRelease 0
# define unixShmLock 0
+# define unixShmBarrier 0
# define unixShmClose 0
#endif /* #ifndef SQLITE_OMIT_WAL */
@@ -3952,6 +3971,7 @@ static const sqlite3_io_methods METHOD = { \
unixShmGet, /* xShmGet */ \
unixShmRelease, /* xShmRelease */ \
unixShmLock, /* xShmLock */ \
+ unixShmBarrier, /* xShmBarrier */ \
unixShmClose /* xShmClose */ \
}; \
static const sqlite3_io_methods *FINDER##Impl(const char *z, unixFile *p){ \