-C Use\sa\sglobal\svariable\sprotected\sby\sa\smutex\sinstead\sof\sthread-specific-data\sto\srecord\smalloc()\sfailures.\s(CVS\s2972)
-D 2006-01-18T16:51:35
+C Modify\sthe\ssqlite3OsInMutex\sos-layer\sinterface\sto\stake\sa\ssingle\sparameter\nto\sdistinguish\sbetween\smutexes\sheld\sby\sthe\scurrent\sthread\sand\smutexes\sheld\nby\sany\sthread.\s\sPart\sof\sthe\sfix\sfor\sticket\s#1630.\s(CVS\s2973)
+D 2006-01-18T17:25:46
F Makefile.in ab3ffd8d469cef4477257169b82810030a6bb967
F Makefile.linux-gcc aee18d8a05546dcf1888bd4547e442008a49a092
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
F src/main.c fe0ec40a2cc4d405a6f18884302f61b2b9961351
F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217
F src/os.c 1d1a61cdf150e9f9520a3bc787c8465148ea2e78
-F src/os.h 9debc3d3ca4cdafde222a0ea74a4c8415aef4f22
+F src/os.h e4637eadcd5a9ca079029078d31751ae295fb05e
F src/os_common.h 95b29ca6f3e6636cb33c9219b3f91a96fa7224b1
F src/os_test.c 49833426101f99aee4bb5f6a44b7c4b2029fda1c
F src/os_test.h 903c93554c23d88f34f667f1979e4a1cee792af3
-F src/os_unix.c 51fa18a26a390912b02cf3c7c5440bce0893a2cd
+F src/os_unix.c 9d44bcfbc1e0997331acec827027637dbe9d7131
F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
-F src/os_win.c a1584b153521d2cd46eb7f1ba11e756a158214db
+F src/os_win.c 98e4e38db7d4a00647b2bb1c60d28b7ca5034c03
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
-F src/pager.c 099b24285de0a649a666e9514d5fd06265cd52cb
+F src/pager.c 651fda1756c2334009e14bfdc652aadbdbed4e8c
F src/pager.h e0acb095b3ad0bca48f2ab00c87346665643f64f
F src/parse.y 83df51fea35f68f7e07384d75dce83d1ed30434c
F src/pragma.c 4496cc77dc35824e1c978c3d1413b8a5a4c777d3
F src/trigger.c 4d3644cbd16959b568c95ae73493402be8021b08
F src/update.c 14be4ba2f438919b4217085c02feff569e6cf1f2
F src/utf.c 5ab8ca05d4e9ec81174b010f01ab12a232f0087d
-F src/util.c be92fe7252c3de3daf5d31f5e092034d722a1b78
+F src/util.c b916d21774e6259d86e875df399dbe1a28e69b8e
F src/vacuum.c 3865673cc66acd0717ecd517f6b8fdb2a5e7924b
F src/vdbe.c 5af32281e96b2c3e29f50975a86b9f5eef044057
F src/vdbe.h 8729a4ee16ff9aeab2af9667df3cf300ff978e13
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P 4de5c52920c94e2a29ef4b68eb8b990c63005b3d
-R 403ff22c240e689bfcaace78e8d9476c
-U danielk1977
-Z ac23f94436e405c8af5dead1d9e7f57e
+P ac090f2ab3b5a792c2fdf897e10060f263e0d408
+R 789c880886342b50e95c468de56aedb9
+U drh
+Z cf39b9ccff84563836ed01af4518e925
-ac090f2ab3b5a792c2fdf897e10060f263e0d408
\ No newline at end of file
+e1ad9df1cf46287f2a7789275e98d28e05880e17
\ No newline at end of file
int sqlite3OsCurrentTime(double*);
void sqlite3OsEnterMutex(void);
void sqlite3OsLeaveMutex(void);
-int sqlite3OsInMutex(void);
+int sqlite3OsInMutex(int);
ThreadData *sqlite3OsThreadSpecificData(int);
void *sqlite3OsMalloc(int);
void *sqlite3OsRealloc(void *, int);
** Release a lockInfo structure previously allocated by findLockInfo().
*/
static void releaseLockInfo(struct lockInfo *pLock){
- assert( sqlite3OsInMutex() );
+ assert( sqlite3OsInMutex(1) );
pLock->nRef--;
if( pLock->nRef==0 ){
sqlite3HashInsert(&lockHash, &pLock->key, sizeof(pLock->key), 0);
** Release a openCnt structure previously allocated by findLockInfo().
*/
static void releaseOpenCnt(struct openCnt *pOpen){
- assert( sqlite3OsInMutex() );
+ assert( sqlite3OsInMutex(1) );
pOpen->nRef--;
if( pOpen->nRef==0 ){
sqlite3HashInsert(&openHash, &pOpen->key, sizeof(pOpen->key), 0);
rc = fstat(fd, &statbuf);
if( rc!=0 ) return 1;
- assert( sqlite3OsInMutex() );
+ assert( sqlite3OsInMutex(1) );
memset(&key1, 0, sizeof(key1));
key1.dev = statbuf.st_dev;
key1.ino = statbuf.st_ino;
** SQLite uses only a single Mutex. There is not much critical
** code and what little there is executes quickly and without blocking.
**
-** This mutex is not recursive.
+** As of version 3.3.2, this mutex must be recursive.
*/
void sqlite3UnixEnterMutex(){
#ifdef SQLITE_UNIX_THREADS
}
/*
-** Return TRUE if we are currently within the mutex and FALSE if not.
+** Return TRUE if the mutex is currently held.
+**
+** If the thisThreadOnly parameter is true, return true only if the
+** calling thread holds the mutex. If the parameter is false, return
+** true if any thread holds the mutex.
*/
-int sqlite3UnixInMutex(){
+int sqlite3UnixInMutex(int thisThreadOnly){
#ifdef SQLITE_UNIX_THREADS
- return inMutex && pthread_equal(mutexOwner, pthread_self());
+ return inMutex>0 &&
+ (thisThreadOnly==0 || pthread_equal(mutexOwner, pthread_self()));
#else
- return inMutex;
+ return inMutex>0;
#endif
}
*/
static int inMutex = 0;
#ifdef SQLITE_W32_THREADS
- static HANDLE mutexOwner;
+ static DWORD mutexOwner;
static CRITICAL_SECTION cs;
#endif
/*
-** The following pair of routine implement mutual exclusion for
+** The following pair of routines implement mutual exclusion for
** multi-threaded processes. Only a single thread is allowed to
** executed code that is surrounded by EnterMutex() and LeaveMutex().
**
** SQLite uses only a single Mutex. There is not much critical
** code and what little there is executes quickly and without blocking.
+**
+** Version 3.3.1 and earlier used a simple mutex. Beginning with
+** version 3.3.2, a recursive mutex is required.
*/
void sqlite3WinEnterMutex(){
#ifdef SQLITE_W32_THREADS
}
}
EnterCriticalSection(&cs);
- mutexOwner = GetCurrentThread();
+ mutexOwner = GetCurrentThreadId();
#endif
inMutex++;
}
assert( inMutex );
inMutex--;
#ifdef SQLITE_W32_THREADS
+ assert( mutexOwner==GetCurrentThreadId() );
LeaveCriticalSection(&cs);
#endif
}
/*
-** Return TRUE if we are currently within the mutex and FALSE if not.
+** Return TRUE if the mutex is currently held.
+**
+** If the thisThreadOnly parameter is true, return true if and only if the
+** calling thread holds the mutex. If the parameter is false, return
+** true if any thread holds the mutex.
*/
-int sqlite3WinInMutex(){
+int sqlite3WinInMutex(int thisThreadOnly){
#ifdef SQLITE_W32_THREADS
- return inMutex && mutexOwner==GetCurrentThread();
+ return inMutex>0 && (thisThreadOnly==0 || mutexOwner==GetCurrentThreadId());
#else
- return inMutex;
+ return inMutex>0;
#endif
}
** file simultaneously, or one process from reading the database while
** another is writing.
**
-** @(#) $Id: pager.c,v 1.243 2006/01/18 16:51:35 danielk1977 Exp $
+** @(#) $Id: pager.c,v 1.244 2006/01/18 17:25:46 drh Exp $
*/
#ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h"
** some of the code invoked by this function may also
** try to obtain the mutex, resulting in a deadlock.
*/
- if( sqlite3OsInMutex() ){
+ if( sqlite3OsInMutex(0) ){
return 0;
}
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
-** $Id: util.c,v 1.176 2006/01/18 16:51:36 danielk1977 Exp $
+** $Id: util.c,v 1.177 2006/01/18 17:25:46 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
** to sqlite3ApiExit(), or false otherwise.
*/
int sqlite3MallocFailed(){
- return (mallocHasFailed && sqlite3OsInMutex());
+ return (mallocHasFailed && sqlite3OsInMutex(1));
}
/*