mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-12 13:01:09 +03:00
Define an invariant to guarantee deadlock-free operation of SHM in os_unix.c
and check that invariant with assert() statements. FossilOrigin-Name: 6af2dca75b8139134ea394c1d71aefc6523f02e9
This commit is contained in:
18
manifest
18
manifest
@@ -1,8 +1,8 @@
|
|||||||
-----BEGIN PGP SIGNED MESSAGE-----
|
-----BEGIN PGP SIGNED MESSAGE-----
|
||||||
Hash: SHA1
|
Hash: SHA1
|
||||||
|
|
||||||
C Rework\smutexes\son\sthe\sSHM\simplemention\sfor\sos_unix\sto\savoid\sa\sdeadlock\sduring\nWAL\srecovery.
|
C Define\san\sinvariant\sto\sguarantee\sdeadlock-free\soperation\sof\sSHM\sin\sos_unix.c\nand\scheck\sthat\sinvariant\swith\sassert()\sstatements.
|
||||||
D 2010-05-01T17:50:38
|
D 2010-05-01T17:57:36
|
||||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||||
F Makefile.in d83a0ffef3dcbfb08b410a6c6dd6c009ec9167fb
|
F Makefile.in d83a0ffef3dcbfb08b410a6c6dd6c009ec9167fb
|
||||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||||
@@ -153,7 +153,7 @@ F src/os.c 8bc63cf91e9802e2b807198e54e50227fa889306
|
|||||||
F src/os.h 534b082c3cb349ad05fa6fa0b06087e022af282c
|
F src/os.h 534b082c3cb349ad05fa6fa0b06087e022af282c
|
||||||
F src/os_common.h 0d6ee583b6ee3185eb9d951f890c6dd03021a08d
|
F src/os_common.h 0d6ee583b6ee3185eb9d951f890c6dd03021a08d
|
||||||
F src/os_os2.c 8ad77a418630d7dee91d1bb04f79c2096301d3a0
|
F src/os_os2.c 8ad77a418630d7dee91d1bb04f79c2096301d3a0
|
||||||
F src/os_unix.c d402146bd3731575ff399d2ebcdc0867034e8451
|
F src/os_unix.c bb8b65d92a79b4b1311fad7cae8a697dea0b8838
|
||||||
F src/os_win.c a8fc01d8483be472e495793c01064fd87e56a5c1
|
F src/os_win.c a8fc01d8483be472e495793c01064fd87e56a5c1
|
||||||
F src/pager.c e9c7fe979b32a3c5bf4216d8fbe1cf8beff8a1b8
|
F src/pager.c e9c7fe979b32a3c5bf4216d8fbe1cf8beff8a1b8
|
||||||
F src/pager.h 934b598583a9d936bb13c37d62a2fe68ac48781c
|
F src/pager.h 934b598583a9d936bb13c37d62a2fe68ac48781c
|
||||||
@@ -811,14 +811,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
|||||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||||
P 9b230c43dfa112e3e1589f9775926807bd36b36e
|
P 1a0f69bef2c489e81a3d4b910b426972e9ed4054
|
||||||
R 70dfb91700ac677788e5556f2fcdd9f6
|
R 9a63fdaeb48f811dfa07166dc0124f9e
|
||||||
U drh
|
U drh
|
||||||
Z aec6f98e0ebcce7f7132104408636399
|
Z 0ec029f9a2c3c35cece8a5840fe4c2a0
|
||||||
-----BEGIN PGP SIGNATURE-----
|
-----BEGIN PGP SIGNATURE-----
|
||||||
Version: GnuPG v1.4.6 (GNU/Linux)
|
Version: GnuPG v1.4.6 (GNU/Linux)
|
||||||
|
|
||||||
iD8DBQFL3GnyoxKgR168RlERAm3bAJwJDWmdlrwEHnjKELzYU8/fifSwAQCeNiz2
|
iD8DBQFL3GuToxKgR168RlERAruJAJ93UG+yjpg4IAjppTK82HawrL2+6ACfZrj+
|
||||||
E59QAYMayqNW9OBp4QF0LdQ=
|
F2hwX359XH9Tj7T1X7t3awQ=
|
||||||
=o6hV
|
=0PFi
|
||||||
-----END PGP SIGNATURE-----
|
-----END PGP SIGNATURE-----
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
1a0f69bef2c489e81a3d4b910b426972e9ed4054
|
6af2dca75b8139134ea394c1d71aefc6523f02e9
|
||||||
@@ -4589,6 +4589,12 @@ typedef struct unixShmFile unixShmFile;
|
|||||||
** Either unixShmFile.mutex must be held or unixShmFile.nRef==0 and
|
** Either unixShmFile.mutex must be held or unixShmFile.nRef==0 and
|
||||||
** unixMutexHeld() is true when reading or writing any other field
|
** unixMutexHeld() is true when reading or writing any other field
|
||||||
** in this structure.
|
** in this structure.
|
||||||
|
**
|
||||||
|
** To avoid deadlocks, mutex and mutexBuf are always released in the
|
||||||
|
** reverse order that they are acquired. mutexBuf is always acquired
|
||||||
|
** first and released last. This invariant is check by asserting
|
||||||
|
** sqlite3_mutex_notheld() on mutex whenever mutexBuf is acquired or
|
||||||
|
** released.
|
||||||
*/
|
*/
|
||||||
struct unixShmFile {
|
struct unixShmFile {
|
||||||
struct unixFileId fid; /* Unique file identifier */
|
struct unixFileId fid; /* Unique file identifier */
|
||||||
@@ -5146,6 +5152,7 @@ static int unixShmGet(
|
|||||||
int rc = SQLITE_OK;
|
int rc = SQLITE_OK;
|
||||||
|
|
||||||
if( p->lockState!=SQLITE_SHM_CHECKPOINT && p->hasMutexBuf==0 ){
|
if( p->lockState!=SQLITE_SHM_CHECKPOINT && p->hasMutexBuf==0 ){
|
||||||
|
assert( sqlite3_mutex_notheld(pFile->mutex) );
|
||||||
sqlite3_mutex_enter(pFile->mutexBuf);
|
sqlite3_mutex_enter(pFile->mutexBuf);
|
||||||
p->hasMutexBuf = 1;
|
p->hasMutexBuf = 1;
|
||||||
}
|
}
|
||||||
@@ -5184,6 +5191,7 @@ static int unixShmRelease(sqlite3_shm *pSharedMem){
|
|||||||
unixShm *p = (unixShm*)pSharedMem;
|
unixShm *p = (unixShm*)pSharedMem;
|
||||||
if( p->hasMutexBuf && p->lockState!=SQLITE_SHM_RECOVER ){
|
if( p->hasMutexBuf && p->lockState!=SQLITE_SHM_RECOVER ){
|
||||||
unixShmFile *pFile = p->pFile;
|
unixShmFile *pFile = p->pFile;
|
||||||
|
assert( sqlite3_mutex_notheld(pFile->mutex) );
|
||||||
sqlite3_mutex_leave(pFile->mutexBuf);
|
sqlite3_mutex_leave(pFile->mutexBuf);
|
||||||
p->hasMutexBuf = 0;
|
p->hasMutexBuf = 0;
|
||||||
}
|
}
|
||||||
@@ -5246,6 +5254,7 @@ static int unixShmLock(
|
|||||||
p->id, getpid(), azLkName[p->lockState], azLkName[desiredLock]));
|
p->id, getpid(), azLkName[p->lockState], azLkName[desiredLock]));
|
||||||
|
|
||||||
if( desiredLock==SQLITE_SHM_RECOVER && !p->hasMutexBuf ){
|
if( desiredLock==SQLITE_SHM_RECOVER && !p->hasMutexBuf ){
|
||||||
|
assert( sqlite3_mutex_notheld(pFile->mutex) );
|
||||||
sqlite3_mutex_enter(pFile->mutexBuf);
|
sqlite3_mutex_enter(pFile->mutexBuf);
|
||||||
p->hasMutexBuf = 1;
|
p->hasMutexBuf = 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user