1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

Be sure to release all wal-index locks before closing the wal-index.

FossilOrigin-Name: b15b67fa14ff77963f470678ff6188c63be8e079
This commit is contained in:
drh
2010-05-04 17:38:42 +00:00
parent cd058ec4ef
commit a8e654eb38
3 changed files with 25 additions and 12 deletions

View File

@@ -562,6 +562,19 @@ finished:
return rc;
}
/*
** Close an open wal-index
*/
static void walIndexClose(Wal *pWal){
sqlite3_shm *pWIndex = pWal->pWIndex;
if( pWIndex ){
sqlite3_vfs *pVfs = pWal->pVfs;
int notUsed;
pVfs->xShmLock(pVfs, pWIndex, SQLITE_SHM_UNLOCK, &notUsed);
pVfs->xShmClose(pVfs, pWIndex, 0);
}
}
/*
** Open a connection to the log file associated with database zDb. The
** database file does not actually have to exist. zDb is used only to
@@ -613,7 +626,7 @@ int sqlite3WalOpen(
}
if( rc!=SQLITE_OK ){
if( pRet->pWIndex ) pVfs->xShmClose(pVfs, pRet->pWIndex, 0);
walIndexClose(pRet);
sqlite3OsClose(pRet->pFd);
sqlite3_free(pRet);
}else{
@@ -819,7 +832,7 @@ int sqlite3WalClose(
walIndexUnmap(pWal);
}
pWal->pVfs->xShmClose(pWal->pVfs, pWal->pWIndex, isDelete);
walIndexClose(pWal);
sqlite3OsClose(pWal->pFd);
if( isDelete ){
sqlite3OsDelete(pWal->pVfs, pWal->zName, 0);