------BEGIN PGP SIGNED MESSAGE-----
-Hash: SHA1
-
-C Enhancements\sto\sthe\ssecure_delete\spragma\sto\smake\sit\seasier\sto\suse.
-D 2010-02-12T19:46:27
+C Merged\stracing\sand\sinitialization\schanges\sfrom\smutex_unix.c.
+D 2010-02-13T02:31:09
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
F src/mutex_noop.c 5f58eaa31f2d742cb8957a747f7887ae98f16053
F src/mutex_os2.c 20477db50cf3817c2f1cd3eb61e5c177e50231db
F src/mutex_unix.c 04a25238abce7e3d06b358dcf706e26624270809
-F src/mutex_w32.c 9ec75bcef0ca722821be7968c320fd725abfb984
+F src/mutex_w32.c 90c3bd10db9f2c30b1f24a1885b54a8a263ff86a
F src/notify.c f799bbda67ab6619b36b0a24153b49518874a203
F src/os.c 8bc63cf91e9802e2b807198e54e50227fa889306
F src/os.h 534b082c3cb349ad05fa6fa0b06087e022af282c
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P f72f8a870a0fc98a9f2b564ffafe7946bbce506e
-R b61a1284585a029b8ec102ac4156fb15
-U drh
-Z d9b19f603d580b3226157728109cbbd5
------BEGIN PGP SIGNATURE-----
-Version: GnuPG v1.4.6 (GNU/Linux)
-
-iD8DBQFLdbAVoxKgR168RlERAj5YAJ42YouMVbChw0/Wmuc1J2A6U9XZigCeJm/S
-8JFH6+GHy+lsobZdTvVyj/I=
-=Aq2n
------END PGP SIGNATURE-----
+P 2bb38bb96ff6b9fb91dd1cf214041cf113ac5508
+R 232b63cb29b9e4506009aea6dd09a4d6
+U shaneh
+Z 85585006145b2cc2993f7e2137036d14
int id; /* Mutex type */
int nRef; /* Number of enterances */
DWORD owner; /* Thread holding this mutex */
+#ifdef SQLITE_DEBUG
+ int trace; /* True to trace changes */
+#endif
};
+#define SQLITE_W32_MUTEX_INITIALIZER { 0 }
+#ifdef SQLITE_DEBUG
+#define SQLITE3_MUTEX_INITIALIZER { SQLITE_W32_MUTEX_INITIALIZER, 0, 0L, (DWORD)0, 0 }
+#else
+#define SQLITE3_MUTEX_INITIALIZER { SQLITE_W32_MUTEX_INITIALIZER, 0, 0L, (DWORD)0 }
+#endif
/*
** Return true (non-zero) if we are running under WinNT, Win2K, WinXP,
static int winMutexHeld(sqlite3_mutex *p){
return p->nRef!=0 && p->owner==GetCurrentThreadId();
}
+static int winMutexNotheld2(sqlite3_mutex *p, DWORD tid){
+ return p->nRef==0 || p->owner!=tid;
+}
static int winMutexNotheld(sqlite3_mutex *p){
- return p->nRef==0 || p->owner!=GetCurrentThreadId();
+ DWORD tid = GetCurrentThreadId();
+ return winMutexNotheld2(p, tid);
}
#endif
/*
** Initialize and deinitialize the mutex subsystem.
*/
-static sqlite3_mutex winMutex_staticMutexes[6];
+static sqlite3_mutex winMutex_staticMutexes[6] = {
+ SQLITE3_MUTEX_INITIALIZER,
+ SQLITE3_MUTEX_INITIALIZER,
+ SQLITE3_MUTEX_INITIALIZER,
+ SQLITE3_MUTEX_INITIALIZER,
+ SQLITE3_MUTEX_INITIALIZER,
+ SQLITE3_MUTEX_INITIALIZER
+};
static int winMutex_isInit = 0;
/* As winMutexInit() and winMutexEnd() are called as part
** of the sqlite3_initialize and sqlite3_shutdown()
** more than once, the behavior is undefined.
*/
static void winMutexEnter(sqlite3_mutex *p){
- assert( p->id==SQLITE_MUTEX_RECURSIVE || winMutexNotheld(p) );
+ DWORD tid = GetCurrentThreadId();
+ assert( p->id==SQLITE_MUTEX_RECURSIVE || winMutexNotheld2(p, tid) );
EnterCriticalSection(&p->mutex);
- p->owner = GetCurrentThreadId();
+ p->owner = tid;
p->nRef++;
+#ifdef SQLITE_DEBUG
+ if( p->trace ){
+ printf("enter mutex %p (%d) with nRef=%d\n", p, p->trace, p->nRef);
+ }
+#endif
}
static int winMutexTry(sqlite3_mutex *p){
+ DWORD tid = GetCurrentThreadId();
int rc = SQLITE_BUSY;
- assert( p->id==SQLITE_MUTEX_RECURSIVE || winMutexNotheld(p) );
+ assert( p->id==SQLITE_MUTEX_RECURSIVE || winMutexNotheld2(p, tid) );
/*
** The sqlite3_mutex_try() routine is very rarely used, and when it
** is used it is merely an optimization. So it is OK for it to always
*/
#if 0
if( mutexIsNT() && TryEnterCriticalSection(&p->mutex) ){
- p->owner = GetCurrentThreadId();
+ p->owner = tid;
p->nRef++;
rc = SQLITE_OK;
}
#else
UNUSED_PARAMETER(p);
+#endif
+#ifdef SQLITE_DEBUG
+ if( rc==SQLITE_OK && p->trace ){
+ printf("enter mutex %p (%d) with nRef=%d\n", p, p->trace, p->nRef);
+ }
#endif
return rc;
}
** is not currently allocated. SQLite will never do either.
*/
static void winMutexLeave(sqlite3_mutex *p){
+ DWORD tid = GetCurrentThreadId();
assert( p->nRef>0 );
- assert( p->owner==GetCurrentThreadId() );
+ assert( p->owner==tid );
p->nRef--;
assert( p->nRef==0 || p->id==SQLITE_MUTEX_RECURSIVE );
LeaveCriticalSection(&p->mutex);
+#ifdef SQLITE_DEBUG
+ if( p->trace ){
+ printf("leave mutex %p (%d) with nRef=%d\n", p, p->trace, p->nRef);
+ }
+#endif
}
sqlite3_mutex_methods *sqlite3DefaultMutex(void){