aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2009-05-29 11:57:38 +0000
committerdrh <drh@noemail.net>2009-05-29 11:57:38 +0000
commit9fe769f12943e4bf1101d8cfa4cdb8fe84ef3df5 (patch)
tree40332d9f764e3c803af1d1467af3c1eea72f3026 /src
parentcc0acb261e25903edee57d036af2ae2fff872b6d (diff)
downloadsqlite-9fe769f12943e4bf1101d8cfa4cdb8fe84ef3df5.tar.gz
sqlite-9fe769f12943e4bf1101d8cfa4cdb8fe84ef3df5.zip
Still more refinements to the hasHotJournal() fix of ticket #3883. (CVS 6689)
FossilOrigin-Name: 726b425e43e5d864e7e83853bdf134debc1ffb59
Diffstat (limited to 'src')
-rw-r--r--src/pager.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/pager.c b/src/pager.c
index 98f93116c..274949043 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.589 2009/05/29 10:55:30 drh Exp $
+** @(#) $Id: pager.c,v 1.590 2009/05/29 11:57:38 drh Exp $
*/
#ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h"
@@ -3391,7 +3391,7 @@ static int hasHotJournal(Pager *pPager, int *pExists){
** we get to the following sqlite3OsCheckReservedLock() call. If that
** is the case, this routine might think there is a hot journal when
** in fact there is none. This results in a false-positive which will
- ** be dealt with by the playback routine under. Ticket #3883.
+ ** be dealt with by the playback routine. Ticket #3883.
*/
rc = sqlite3OsCheckReservedLock(pPager->fd, &locked);
if( rc==SQLITE_OK && !locked ){
@@ -3400,16 +3400,18 @@ static int hasHotJournal(Pager *pPager, int *pExists){
/* Check the size of the database file. If it consists of 0 pages,
** then delete the journal file. See the header comment above for
** the reasoning here. Delete the obsolete journal file under
- ** a RESERVED lock to avoid race conditions.
+ ** a RESERVED lock to avoid race conditions and to avoid violating
+ ** [H33020].
*/
rc = sqlite3PagerPagecount(pPager, &nPage);
if( rc==SQLITE_OK ){
if( nPage==0 ){
sqlite3BeginBenignMalloc();
- if( pPager->exclusiveMode
+ if( pPager->state>=PAGER_RESERVED
|| sqlite3OsLock(pPager->fd, RESERVED_LOCK)==SQLITE_OK ){
sqlite3OsDelete(pVfs, pPager->zJournal, 0);
- if( !pPager->exclusiveMode ){
+ assert( pPager->state>=PAGER_SHARED );
+ if( pPager->state==PAGER_SHARED ){
sqlite3OsUnlock(pPager->fd, SHARED_LOCK);
}
}