Get the previous mutex fix working with SQLITE_DEBUG and with the amalgamation.

FossilOrigin-Name: df19928f7ee94bca3989313ff16507c15d6efe2b
This commit is contained in:
drh 2010-05-05 00:22:21 +00:00
parent 92d7652379
commit fc34ad291e
3 changed files with 31 additions and 25 deletions

View File

@ -1,8 +1,8 @@
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
C When\sthe\sin\ssingle-threaded\smode,\sthe\ssqlite3_mutex_alloc()\sinterface\nstill\sreturns\sa\snon-NULL\svalue.\s\sThe\smutex\sdoesn't\sdo\sanything,\sbut\sit\ntests\snon-NULL.\s\sThis\sway,\sextensions\s(or\sVFSes)\sthat\suse\ssqlite3_mutex_alloc()\ncan\stell\sthe\sdifference\sbetween\san\sOOM\serror\sand\smutexes\sbeing\sdisabled.
D 2010-05-05T00:05:24
C Get\sthe\sprevious\smutex\sfix\sworking\swith\sSQLITE_DEBUG\sand\swith\sthe\samalgamation.
D 2010-05-05T00:22:21
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in d83a0ffef3dcbfb08b410a6c6dd6c009ec9167fb
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -144,7 +144,7 @@ F src/mem5.c eb7a5cb98915dd7a086fa415ce3a5a0f20d0acff
F src/memjournal.c f3be374af30588de297dcf678925b2a4758e4135
F src/mutex.c e2358d8f9a9021ab0bba4d511bb701e471e6e5f6
F src/mutex.h 6fde601e55fa6c3fae768783c439797ab84c87c6
F src/mutex_noop.c 7dcd084c1ecb6258b7da824fa0feb7d9ebd537d5
F src/mutex_noop.c 3905184c3e1ebc72a5e40f97814dae5b02a33be1
F src/mutex_os2.c 20477db50cf3817c2f1cd3eb61e5c177e50231db
F src/mutex_unix.c 04a25238abce7e3d06b358dcf706e26624270809
F src/mutex_w32.c 4cc201c1bfd11d1562810554ff5500e735559d7e
@ -812,14 +812,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P 4016b422286587beda7323052d27821adb1fed73
R 87640419095dfdb05fcc49f65da51e46
P 451fd175758983c335aab449fdc4cb838156c4cb
R 045e2e841d66b6071070228cb0d8c719
U drh
Z 50e1e779e0d4bec5a929210a4c6c0526
Z 28121b315f3da7a423e5bbc25a4e7e69
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFL4LZKoxKgR168RlERAvf5AJ4yZOjWI5iQUOpLK97VFh220LzPgwCdHHWu
b+V9an+7FFUytUxF3xEa9/c=
=qvND
iD8DBQFL4LpAoxKgR168RlERAs4JAJ9mYm8FUjs24AAvPT3+A1OTbH8RHACdFekG
3tezMw8gAYDoEh0uXo6E0oE=
=HyII
-----END PGP SIGNATURE-----

View File

@ -1 +1 @@
451fd175758983c335aab449fdc4cb838156c4cb
df19928f7ee94bca3989313ff16507c15d6efe2b

View File

@ -72,19 +72,21 @@ sqlite3_mutex_methods *sqlite3NoopMutex(void){
/*
** The mutex object
*/
struct sqlite3_mutex {
typedef struct sqlite3_debug_mutex {
int id; /* The mutex type */
int cnt; /* Number of entries without a matching leave */
};
} sqlite3_debug_mutex;
/*
** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are
** intended for use inside assert() statements.
*/
static int debugMutexHeld(sqlite3_mutex *p){
static int debugMutexHeld(sqlite3_mutex *pX){
sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;
return p==0 || p->cnt>0;
}
static int debugMutexNotheld(sqlite3_mutex *p){
static int debugMutexNotheld(sqlite3_mutex *pX){
sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;
return p==0 || p->cnt==0;
}
@ -100,8 +102,8 @@ static int debugMutexEnd(void){ return SQLITE_OK; }
** that means that a mutex could not be allocated.
*/
static sqlite3_mutex *debugMutexAlloc(int id){
static sqlite3_mutex aStatic[6];
sqlite3_mutex *pNew = 0;
static sqlite3_debug_mutex aStatic[6];
sqlite3_debug_mutex *pNew = 0;
switch( id ){
case SQLITE_MUTEX_FAST:
case SQLITE_MUTEX_RECURSIVE: {
@ -120,13 +122,14 @@ static sqlite3_mutex *debugMutexAlloc(int id){
break;
}
}
return pNew;
return (sqlite3_mutex*)pNew;
}
/*
** This routine deallocates a previously allocated mutex.
*/
static void debugMutexFree(sqlite3_mutex *p){
static void debugMutexFree(sqlite3_mutex *pX){
sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;
assert( p->cnt==0 );
assert( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE );
sqlite3_free(p);
@ -143,12 +146,14 @@ static void debugMutexFree(sqlite3_mutex *p){
** can enter. If the same thread tries to enter any other kind of mutex
** more than once, the behavior is undefined.
*/
static void debugMutexEnter(sqlite3_mutex *p){
assert( p->id==SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(p) );
static void debugMutexEnter(sqlite3_mutex *pX){
sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;
assert( p->id==SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(pX) );
p->cnt++;
}
static int debugMutexTry(sqlite3_mutex *p){
assert( p->id==SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(p) );
static int debugMutexTry(sqlite3_mutex *pX){
sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;
assert( p->id==SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(pX) );
p->cnt++;
return SQLITE_OK;
}
@ -159,10 +164,11 @@ static int debugMutexTry(sqlite3_mutex *p){
** is undefined if the mutex is not currently entered or
** is not currently allocated. SQLite will never do either.
*/
static void debugMutexLeave(sqlite3_mutex *p){
assert( debugMutexHeld(p) );
static void debugMutexLeave(sqlite3_mutex *pX){
sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;
assert( debugMutexHeld(pX) );
p->cnt--;
assert( p->id==SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(p) );
assert( p->id==SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(pX) );
}
sqlite3_mutex_methods *sqlite3NoopMutex(void){