Add assert() statements to os_unix.c to check that the mutex is held when it should be.
FossilOrigin-Name: 11a669b6537d6bac67764fd91a319234345ac504
This commit is contained in:
parent
6085f5e0a0
commit
9359c7b7ab
14
manifest
14
manifest
@ -1,5 +1,5 @@
|
||||
C Updated\ssqlite3AtoF()\sthat\sperforms\sslightly\sbetter\swith\sGCC,\sand\ssignificantly\sbetter\swith\sMSVC.
|
||||
D 2009-08-21T02:13:14
|
||||
C Add\sassert()\sstatements\sto\sos_unix.c\sto\scheck\sthat\sthe\smutex\sis\sheld\swhen\sit\sshould\sbe.
|
||||
D 2009-08-21T08:29:10
|
||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||
F Makefile.in 73ddeec9dd10b85876c5c2ce1fdce627e1dcc7f8
|
||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||
@ -145,7 +145,7 @@ F src/os.c 9fea283e336ee31caa4654d6cb05a129a1c42d2f
|
||||
F src/os.h 00a1334a4eecee7f7bef79ac606b88d325119f21
|
||||
F src/os_common.h 8c61457df58f1a4bd5f5adc3e90e01b37bf7afbc
|
||||
F src/os_os2.c bed77dc26e3a95ce4a204936b9a1ca6fe612fcc5
|
||||
F src/os_unix.c 6895098a9e7bd5630fab59060da6397bebcf2ff9
|
||||
F src/os_unix.c 85f6ed28690a3c4546edaa25252d52761490aa33
|
||||
F src/os_win.c 58bb163f327e79726dd119344d908e4d98483c3f
|
||||
F src/pager.c a47be286477ed6c7b9a342dd53d4e4043f29d8c2
|
||||
F src/pager.h 11852d044c86cf5a9d6e34171fb0c4fcf1f6265f
|
||||
@ -747,7 +747,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||
F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746
|
||||
P 3ba316e9a32de406a4390fb3f52fccb48da4da30
|
||||
R bbc63800e202da4f72f0395afa840353
|
||||
U shane
|
||||
Z aada4480e610c2af2b7cf949ce420cab
|
||||
P f084f5a8ba850de627ca8e9de6c81ab1ad9b7a1b
|
||||
R 86b75a5cb6d64dfb1579ca1b08107e59
|
||||
U dan
|
||||
Z 23bb429f975133621e0fd91ccb484fc5
|
||||
|
@ -1 +1 @@
|
||||
f084f5a8ba850de627ca8e9de6c81ab1ad9b7a1b
|
||||
11a669b6537d6bac67764fd91a319234345ac504
|
@ -260,7 +260,18 @@ struct unixFile {
|
||||
|
||||
|
||||
/*
|
||||
** Helper functions to obtain and relinquish the global mutex.
|
||||
** Helper functions to obtain and relinquish the global mutex. The
|
||||
** global mutex is used to protect the unixOpenCnt, unixLockInfo and
|
||||
** vxworksFileId objects used by this file, all of which may be
|
||||
** shared by multiple threads.
|
||||
**
|
||||
** Function unixMutexHeld() is used to assert() that the global mutex
|
||||
** is held when required. This function is only used as part of assert()
|
||||
** statements. e.g.
|
||||
**
|
||||
** unixEnterMutex()
|
||||
** assert( unixMutexHeld() );
|
||||
** unixEnterLeave()
|
||||
*/
|
||||
static void unixEnterMutex(void){
|
||||
sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
|
||||
@ -268,6 +279,11 @@ static void unixEnterMutex(void){
|
||||
static void unixLeaveMutex(void){
|
||||
sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
|
||||
}
|
||||
#ifdef SQLITE_DEBUG
|
||||
static int unixMutexHeld(void) {
|
||||
return sqlite3_mutex_held(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef SQLITE_DEBUG
|
||||
@ -278,11 +294,11 @@ static void unixLeaveMutex(void){
|
||||
*/
|
||||
static const char *locktypeName(int locktype){
|
||||
switch( locktype ){
|
||||
case NO_LOCK: return "NONE";
|
||||
case SHARED_LOCK: return "SHARED";
|
||||
case RESERVED_LOCK: return "RESERVED";
|
||||
case PENDING_LOCK: return "PENDING";
|
||||
case EXCLUSIVE_LOCK: return "EXCLUSIVE";
|
||||
case NO_LOCK: return "NONE";
|
||||
case SHARED_LOCK: return "SHARED";
|
||||
case RESERVED_LOCK: return "RESERVED";
|
||||
case PENDING_LOCK: return "PENDING";
|
||||
case EXCLUSIVE_LOCK: return "EXCLUSIVE";
|
||||
}
|
||||
return "ERROR";
|
||||
}
|
||||
@ -737,7 +753,7 @@ struct unixOpenCnt {
|
||||
int nRef; /* Number of pointers to this structure */
|
||||
int nLock; /* Number of outstanding locks */
|
||||
int nPending; /* Number of pending close() operations */
|
||||
int *aPending; /* Malloced space holding fd's awaiting a close() */
|
||||
int *aPending; /* Malloced space holding fds awaiting close() */
|
||||
#if OS_VXWORKS
|
||||
sem_t *pSem; /* Named POSIX semaphore */
|
||||
char aSemName[MAX_PATHNAME+1]; /* Name of that semaphore */
|
||||
@ -848,8 +864,12 @@ static void testThreadLockingBehavior(int fd_orig){
|
||||
|
||||
/*
|
||||
** Release a unixLockInfo structure previously allocated by findLockInfo().
|
||||
**
|
||||
** The mutex entered using the unixEnterMutex() function must be held
|
||||
** when this function is called.
|
||||
*/
|
||||
static void releaseLockInfo(struct unixLockInfo *pLock){
|
||||
assert( unixMutexHeld() );
|
||||
if( pLock ){
|
||||
pLock->nRef--;
|
||||
if( pLock->nRef==0 ){
|
||||
@ -871,8 +891,12 @@ static void releaseLockInfo(struct unixLockInfo *pLock){
|
||||
|
||||
/*
|
||||
** Release a unixOpenCnt structure previously allocated by findLockInfo().
|
||||
**
|
||||
** The mutex entered using the unixEnterMutex() function must be held
|
||||
** when this function is called.
|
||||
*/
|
||||
static void releaseOpenCnt(struct unixOpenCnt *pOpen){
|
||||
assert( unixMutexHeld() );
|
||||
if( pOpen ){
|
||||
pOpen->nRef--;
|
||||
if( pOpen->nRef==0 ){
|
||||
@ -898,6 +922,9 @@ static void releaseOpenCnt(struct unixOpenCnt *pOpen){
|
||||
** describes that file descriptor. Create new ones if necessary. The
|
||||
** return values might be uninitialized if an error occurs.
|
||||
**
|
||||
** The mutex entered using the unixEnterMutex() function must be held
|
||||
** when this function is called.
|
||||
**
|
||||
** Return an appropriate error code.
|
||||
*/
|
||||
static int findLockInfo(
|
||||
@ -913,6 +940,8 @@ static int findLockInfo(
|
||||
struct unixLockInfo *pLock = 0;/* Candidate unixLockInfo object */
|
||||
struct unixOpenCnt *pOpen; /* Candidate unixOpenCnt object */
|
||||
|
||||
assert( unixMutexHeld() );
|
||||
|
||||
/* Get low-level information about the file that we can used to
|
||||
** create a unique name for the file.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user