aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2009-05-29 10:55:29 +0000
committerdrh <drh@noemail.net>2009-05-29 10:55:29 +0000
commitcc0acb261e25903edee57d036af2ae2fff872b6d (patch)
tree06cdb7309dc1918e72a5149477fd32823f710b0b /src
parentf0039ad8156775095a22808eec6eb18334ed1deb (diff)
downloadsqlite-cc0acb261e25903edee57d036af2ae2fff872b6d.tar.gz
sqlite-cc0acb261e25903edee57d036af2ae2fff872b6d.zip
The hasHotJournal() fix of check-in (6687) causes some minor problems in
various alternative operating modes, such as locking_mode=EXCLUSIVE. This additional patch attempts to fix those concerns. Ticket #3883. (CVS 6688) FossilOrigin-Name: a2ba61d927a06c390a9a818a013328092b802222
Diffstat (limited to 'src')
-rw-r--r--src/pager.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/pager.c b/src/pager.c
index c4c785147..98f93116c 100644
--- a/src/pager.c
+++ b/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.588 2009/05/29 00:30:30 drh Exp $
+** @(#) $Id: pager.c,v 1.589 2009/05/29 10:55:30 drh Exp $
*/
#ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h"
@@ -3405,10 +3405,15 @@ static int hasHotJournal(Pager *pPager, int *pExists){
rc = sqlite3PagerPagecount(pPager, &nPage);
if( rc==SQLITE_OK ){
if( nPage==0 ){
- if( sqlite3OsLock(pPager->fd, RESERVED_LOCK)==SQLITE_OK ){
+ sqlite3BeginBenignMalloc();
+ if( pPager->exclusiveMode
+ || sqlite3OsLock(pPager->fd, RESERVED_LOCK)==SQLITE_OK ){
sqlite3OsDelete(pVfs, pPager->zJournal, 0);
- sqlite3OsUnlock(pPager->fd, SHARED_LOCK);
+ if( !pPager->exclusiveMode ){
+ sqlite3OsUnlock(pPager->fd, SHARED_LOCK);
+ }
}
+ sqlite3EndBenignMalloc();
}else{
/* The journal file exists and no other connection has a reserved
** or greater lock on the database file. Now check that there is
@@ -3426,7 +3431,7 @@ static int hasHotJournal(Pager *pPager, int *pExists){
}
sqlite3OsClose(pPager->jfd);
*pExists = (first!=0);
- }else{
+ }else if( rc==SQLITE_CANTOPEN ){
/* If we cannot open the rollback journal file in order to see if
** its has a zero header, that might be due to an I/O error, or
** it might be due to the race condition described above and in