From: mistachkin Date: Fri, 3 Jul 2015 23:11:36 +0000 (+0000) Subject: Enhance mutex testing to include APP and VFS static mutexes. X-Git-Tag: version-3.8.11~63 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=28ae577a3d6d48302678929c92123b065a913bb3;p=thirdparty%2Fsqlite.git Enhance mutex testing to include APP and VFS static mutexes. FossilOrigin-Name: 1025873fdfd9e7e53094c48af1a79c60ae50ae97 --- diff --git a/manifest b/manifest index 76c4625bca..29325cfe72 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sstatic\smutexes\sfor\suse\sby\sthe\sbuilt-in\s/\sthird-party\sVFSs\sand\suse\sthe\sbuilt-in\sVFS\smutex\swhere\sappropriate. -D 2015-07-03T21:38:09.670 +C Enhance\smutex\stesting\sto\sinclude\sAPP\sand\sVFS\sstatic\smutexes. +D 2015-07-03T23:11:36.336 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 78db7e3b643002849258892ab2a9df10c24ee63d F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -365,7 +365,7 @@ F src/test_loadext.c a5251f956ab6af21e138dc1f9c0399394a510cb4 F src/test_malloc.c 208f09a4e21defa496bc1094fcfadea19385a112 F src/test_multiplex.c 9fefd23f6cc3fa9bf0748a5e453167e7b9f193ce F src/test_multiplex.h c08e4e8f8651f0c5e0509b138ff4d5b43ed1f5d3 -F src/test_mutex.c 293042d623ebba969160f471a82aa1551626454f +F src/test_mutex.c 486bea424c66005d587e8272b2a742a25d251c73 F src/test_onefile.c 38f7cbe79d5bafe95bde683cc3a53b8ca16daf10 F src/test_osinst.c 5423dc1d355f594371f27dd292ca54bd320b8196 F src/test_pcache.c a5cd24730cb43c5b18629043314548c9169abb00 @@ -868,7 +868,7 @@ F test/multiplex.test efd015ca0b5b4a57dc9535b8feb1273eebeadb60 F test/multiplex2.test 580ca5817c7edbe4cc68fa150609c9473393003a F test/multiplex3.test d228f59eac91839a977eac19f21d053f03e4d101 F test/multiplex4.test e8ae4c4bd70606a5727743241f13b5701990abe4 -F test/mutex1.test 78b2b9bb320e51d156c4efdb71b99b051e7a4b41 +F test/mutex1.test e0a44072d98189003deae4b091106f085d94bea8 F test/mutex2.test bfeaeac2e73095b2ac32285d2756e3a65e681660 F test/nan.test e9648b9d007c7045242af35e11a984d4b169443a F test/nolock.test 0540dd96f39b8876e3ffdd8814fad0ea425efeee @@ -1364,7 +1364,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 0778825d0ec9315c70659fae8d0640b209049dd8 -R c3e93636a97f33c44303b10895e73ee1 +P b202e2a1d73d104d795d2252b1c6f61d65bfb295 +R 1dd264571c6a612a20dc2b3433c44096 U mistachkin -Z 0231ff1cbe7c5e5e0d327907d22772e6 +Z 47fb3c7897d245bf0611496fd190514f diff --git a/manifest.uuid b/manifest.uuid index 3632f6c9ae..6d7bed7cd8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b202e2a1d73d104d795d2252b1c6f61d65bfb295 \ No newline at end of file +1025873fdfd9e7e53094c48af1a79c60ae50ae97 \ No newline at end of file diff --git a/src/test_mutex.c b/src/test_mutex.c index c9b4a29ab7..65d853f775 100644 --- a/src/test_mutex.c +++ b/src/test_mutex.c @@ -19,9 +19,18 @@ #include #include +#define MAX_MUTEXES (SQLITE_MUTEX_STATIC_VFS3+1) + /* defined in main.c */ extern const char *sqlite3ErrName(int); +static const char *aName[MAX_MUTEXES+1] = { + "fast", "recursive", "static_master", "static_mem", + "static_open", "static_prng", "static_lru", "static_pmem", + "static_app1", "static_app2", "static_app3", "static_vfs1", + "static_vfs2", "static_vfs3", 0 +}; + /* A countable mutex */ struct sqlite3_mutex { sqlite3_mutex *pReal; @@ -30,13 +39,13 @@ struct sqlite3_mutex { /* State variables */ static struct test_mutex_globals { - int isInstalled; /* True if installed */ - int disableInit; /* True to cause sqlite3_initalize() to fail */ - int disableTry; /* True to force sqlite3_mutex_try() to fail */ - int isInit; /* True if initialized */ - sqlite3_mutex_methods m; /* Interface to "real" mutex system */ - int aCounter[8]; /* Number of grabs of each type of mutex */ - sqlite3_mutex aStatic[6]; /* The six static mutexes */ + int isInstalled; /* True if installed */ + int disableInit; /* True to cause sqlite3_initalize() to fail */ + int disableTry; /* True to force sqlite3_mutex_try() to fail */ + int isInit; /* True if initialized */ + sqlite3_mutex_methods m; /* Interface to "real" mutex system */ + int aCounter[MAX_MUTEXES]; /* Number of grabs of each type of mutex */ + sqlite3_mutex aStatic[MAX_MUTEXES]; /* The static mutexes */ } g = {0}; /* Return true if the countable mutex is currently held */ @@ -78,7 +87,8 @@ static sqlite3_mutex *counterMutexAlloc(int eType){ sqlite3_mutex *pRet = 0; assert( g.isInit ); - assert(eType<8 && eType>=0); + assert( eType>=SQLITE_MUTEX_FAST ); + assert( eType<=SQLITE_MUTEX_STATIC_VFS3 ); pReal = g.m.xMutexAlloc(eType); if( !pReal ) return 0; @@ -86,7 +96,10 @@ static sqlite3_mutex *counterMutexAlloc(int eType){ if( eType==SQLITE_MUTEX_FAST || eType==SQLITE_MUTEX_RECURSIVE ){ pRet = (sqlite3_mutex *)malloc(sizeof(sqlite3_mutex)); }else{ - pRet = &g.aStatic[eType-2]; + int eStaticType = eType - (SQLITE_MUTEX_RECURSIVE + 1); + assert( eStaticType>=0 ); + assert( eStaticTypeeType = eType; @@ -110,6 +123,8 @@ static void counterMutexFree(sqlite3_mutex *p){ */ static void counterMutexEnter(sqlite3_mutex *p){ assert( g.isInit ); + assert( p->eType>=0 ); + assert( p->eTypeeType]++; g.m.xMutexEnter(p->pReal); } @@ -119,6 +134,8 @@ static void counterMutexEnter(sqlite3_mutex *p){ */ static int counterMutexTry(sqlite3_mutex *p){ assert( g.isInit ); + assert( p->eType>=0 ); + assert( p->eTypeeType]++; if( g.disableTry ) return SQLITE_BUSY; return g.m.xMutexTry(p->pReal); @@ -245,10 +262,6 @@ static int test_read_mutex_counters( ){ Tcl_Obj *pRet; int ii; - char *aName[8] = { - "fast", "recursive", "static_master", "static_mem", - "static_open", "static_prng", "static_lru", "static_pmem" - }; if( objc!=1 ){ Tcl_WrongNumArgs(interp, 1, objv, ""); @@ -257,7 +270,7 @@ static int test_read_mutex_counters( pRet = Tcl_NewObj(); Tcl_IncrRefCount(pRet); - for(ii=0; ii<8; ii++){ + for(ii=0; ii 0} {