aboutsummaryrefslogtreecommitdiff
path: root/src/malloc.c
diff options
context:
space:
mode:
authordan <dan@noemail.net>2010-09-02 10:08:41 +0000
committerdan <dan@noemail.net>2010-09-02 10:08:41 +0000
commitb0c6a8884b6c6e6f996e5452d334a19339ab28e5 (patch)
treec2a942a497d76da012970b8a3b35335f0d5044e2 /src/malloc.c
parent659503a18dcd927afc5301a74a09363c87ee2301 (diff)
downloadsqlite-b0c6a8884b6c6e6f996e5452d334a19339ab28e5.tar.gz
sqlite-b0c6a8884b6c6e6f996e5452d334a19339ab28e5.zip
If MEM_STATUS is disabled, avoid holding the STATIC_MEM mutex when calling the user-defined xMalloc method. Holding the mutex causes problems for memsys3 and memsys5.
FossilOrigin-Name: 4f20f8ba73691c8a1dc33d2fcd1e793dd08f00a8
Diffstat (limited to 'src/malloc.c')
-rw-r--r--src/malloc.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/malloc.c b/src/malloc.c
index ac1910389..f6f75565f 100644
--- a/src/malloc.c
+++ b/src/malloc.c
@@ -352,17 +352,21 @@ void *sqlite3ScratchMalloc(int n){
mem0.nScratchFree--;
sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, 1);
sqlite3StatusSet(SQLITE_STATUS_SCRATCH_SIZE, n);
+ sqlite3_mutex_leave(mem0.mutex);
}else{
if( sqlite3GlobalConfig.bMemstat ){
sqlite3StatusSet(SQLITE_STATUS_SCRATCH_SIZE, n);
n = mallocWithAlarm(n, &p);
if( p ) sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_OVERFLOW, n);
+ sqlite3_mutex_leave(mem0.mutex);
}else{
+ sqlite3_mutex_leave(mem0.mutex);
p = sqlite3GlobalConfig.m.xMalloc(n);
}
sqlite3MemdebugSetType(p, MEMTYPE_SCRATCH);
}
- sqlite3_mutex_leave(mem0.mutex);
+ assert( !sqlite3_mutex_held(mem0.mutex) );
+
#if SQLITE_THREADSAFE==0 && !defined(NDEBUG)
/* Verify that no more than two scratch allocations per thread