diff options
author | drh <drh@noemail.net> | 2012-06-02 14:32:21 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2012-06-02 14:32:21 +0000 |
commit | 4245c405ea9ef9115dd2dd6b81afc10a6edf67d1 (patch) | |
tree | b28f55712f79145318fc5aaed0e1a7927865b44f /src/backup.c | |
parent | ed4668271909964bfa81cc968ccbea5be7f4c15e (diff) | |
download | sqlite-4245c405ea9ef9115dd2dd6b81afc10a6edf67d1.tar.gz sqlite-4245c405ea9ef9115dd2dd6b81afc10a6edf67d1.zip |
The sqlite3_close() interface returns SQLITE_OK even if there are outstanding
sqlite3_stmt and sqlite3_backup objects. The connection becomes a zombie.
Resource deallocation is deferred until the last sqlite3_stmt or
sqlite3_backup object closes. This is intended to help SQLite play nicer
with garbage collectors.
FossilOrigin-Name: e276a02b7f54e804caa553dca99023416a415e1c
Diffstat (limited to 'src/backup.c')
-rw-r--r-- | src/backup.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/backup.c b/src/backup.c index 7a4047f34..6655ee391 100644 --- a/src/backup.c +++ b/src/backup.c @@ -543,14 +543,13 @@ int sqlite3_backup_step(sqlite3_backup *p, int nPage){ */ int sqlite3_backup_finish(sqlite3_backup *p){ sqlite3_backup **pp; /* Ptr to head of pagers backup list */ - MUTEX_LOGIC( sqlite3_mutex *mutex; ) /* Mutex to protect source database */ + sqlite3 *pSrcDb = p->pSrcDb; /* Source database connection */ int rc; /* Value to return */ /* Enter the mutexes */ if( p==0 ) return SQLITE_OK; sqlite3_mutex_enter(p->pSrcDb->mutex); sqlite3BtreeEnter(p->pSrc); - MUTEX_LOGIC( mutex = p->pSrcDb->mutex; ) if( p->pDestDb ){ sqlite3_mutex_enter(p->pDestDb->mutex); } @@ -576,7 +575,7 @@ int sqlite3_backup_finish(sqlite3_backup *p){ /* Exit the mutexes and free the backup context structure. */ if( p->pDestDb ){ - sqlite3_mutex_leave(p->pDestDb->mutex); + sqlite3LeaveMutexAndCloseZombie(p->pDestDb); } sqlite3BtreeLeave(p->pSrc); if( p->pDestDb ){ @@ -585,7 +584,7 @@ int sqlite3_backup_finish(sqlite3_backup *p){ ** sqlite3_backup_finish(). */ sqlite3_free(p); } - sqlite3_mutex_leave(mutex); + sqlite3LeaveMutexAndCloseZombie(pSrcDb); return rc; } |