mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-05 15:55:57 +03:00
Fixes to the OsUnlock() interface. Correctly leave a SHARED lock behind
when requested. Honor the error code that OsUnlock() returns. Ticket #913 and #938. (CVS 1997) FossilOrigin-Name: c4697503d0ad080290b91e96dfc9a1a63f2df7e6
This commit is contained in:
27
src/pager.c
27
src/pager.c
@@ -18,7 +18,7 @@
|
||||
** file simultaneously, or one process from reading the database while
|
||||
** another is writing.
|
||||
**
|
||||
** @(#) $Id: pager.c,v 1.165 2004/10/01 02:00:31 drh Exp $
|
||||
** @(#) $Id: pager.c,v 1.166 2004/10/02 20:38:28 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include "os.h"
|
||||
@@ -755,6 +755,7 @@ static void pager_reset(Pager *pPager){
|
||||
*/
|
||||
static int pager_unwritelock(Pager *pPager){
|
||||
PgHdr *pPg;
|
||||
int rc;
|
||||
assert( !pPager->memDb );
|
||||
if( pPager->state<PAGER_RESERVED ){
|
||||
return SQLITE_OK;
|
||||
@@ -780,11 +781,11 @@ static int pager_unwritelock(Pager *pPager){
|
||||
}else{
|
||||
assert( pPager->dirtyCache==0 || pPager->useJournal==0 );
|
||||
}
|
||||
sqlite3OsUnlock(&pPager->fd, SHARED_LOCK);
|
||||
rc = sqlite3OsUnlock(&pPager->fd, SHARED_LOCK);
|
||||
pPager->state = PAGER_SHARED;
|
||||
pPager->origDbSize = 0;
|
||||
pPager->setMaster = 0;
|
||||
return SQLITE_OK;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2342,20 +2343,15 @@ static int pager_open_journal(Pager *pPager){
|
||||
sqlite3pager_pagecount(pPager);
|
||||
pPager->aInJournal = sqliteMalloc( pPager->dbSize/8 + 1 );
|
||||
if( pPager->aInJournal==0 ){
|
||||
sqlite3OsUnlock(&pPager->fd, SHARED_LOCK);
|
||||
pPager->state = PAGER_SHARED;
|
||||
return SQLITE_NOMEM;
|
||||
rc = SQLITE_NOMEM;
|
||||
goto failed_to_open_journal;
|
||||
}
|
||||
rc = sqlite3OsOpenExclusive(pPager->zJournal, &pPager->jfd,pPager->tempFile);
|
||||
pPager->journalOff = 0;
|
||||
pPager->setMaster = 0;
|
||||
pPager->journalHdr = 0;
|
||||
if( rc!=SQLITE_OK ){
|
||||
sqliteFree(pPager->aInJournal);
|
||||
pPager->aInJournal = 0;
|
||||
sqlite3OsUnlock(&pPager->fd, SHARED_LOCK);
|
||||
pPager->state = PAGER_SHARED;
|
||||
return rc;
|
||||
goto failed_to_open_journal;
|
||||
}
|
||||
sqlite3OsOpenDirectory(pPager->zDirectory, &pPager->jfd);
|
||||
pPager->journalOpen = 1;
|
||||
@@ -2380,7 +2376,14 @@ static int pager_open_journal(Pager *pPager){
|
||||
rc = SQLITE_FULL;
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
return rc;
|
||||
|
||||
failed_to_open_journal:
|
||||
sqliteFree(pPager->aInJournal);
|
||||
pPager->aInJournal = 0;
|
||||
sqlite3OsUnlock(&pPager->fd, NO_LOCK);
|
||||
pPager->state = PAGER_UNLOCK;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user