1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-12 13:01:09 +03:00

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
This commit is contained in:
drh
2010-05-20 23:51:06 +00:00
parent 7e263728f2
commit 286a288493
14 changed files with 135 additions and 41 deletions

View File

@@ -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){ \