1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-24 08:21:29 +03:00

Changes for branch coverage of notify.c. Fixed quirk of

unlock_notify() where it would still think it was blocked
after a callback was cleared (even after the transaction
on the blocking connection was closed).

FossilOrigin-Name: c54e8dad01b0ecaf8d66b10e64e862dcad8a6746
This commit is contained in:
shaneh
2010-04-16 22:05:31 +00:00
parent f391327824
commit 4b93f6bd1e
5 changed files with 28 additions and 24 deletions

View File

@@ -157,6 +157,7 @@ int sqlite3_unlock_notify(
if( xNotify==0 ){
removeFromBlockedList(db);
db->pBlockingConnection = 0;
db->pUnlockConnection = 0;
db->xUnlockNotify = 0;
db->pUnlockArg = 0;
@@ -196,9 +197,14 @@ int sqlite3_unlock_notify(
*/
void sqlite3ConnectionBlocked(sqlite3 *db, sqlite3 *pBlocker){
enterMutex();
if( db->pBlockingConnection==0 && db->pUnlockConnection==0 ){
addToBlockedList(db);
}
if( db->pBlockingConnection==0 ){
/*
** We can not register an unlock callback unless we think we are
** blocked.
*/
assert( db->pUnlockConnection==0 );
addToBlockedList(db);
}
db->pBlockingConnection = pBlocker;
leaveMutex();
}
@@ -301,7 +307,15 @@ void sqlite3ConnectionUnlocked(sqlite3 *db){
}
/* Step 3. */
if( p->pBlockingConnection==0 && p->pUnlockConnection==0 ){
if( p->pBlockingConnection==0 ){
/*
** If we were blocked on db, we would set
** pBlockingConnection to 0 above. And we can
** only wait on a connection we are blocked on.
** So if we were waiting on db (pUnlockConnection==db)
** then it would have been set to 0 above as well.
*/
assert( p->pUnlockConnection==0 );
/* Remove connection p from the blocked connections list. */
*pp = p->pNextBlocked;
p->pNextBlocked = 0;