/ Check-in [b15b67fa]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Be sure to release all wal-index locks before closing the wal-index.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b15b67fa14ff77963f470678ff6188c63be8e079
User & Date: drh 2010-05-04 17:38:42
Context
2010-05-04
18:50
When sqlite3PagerPagecount() is called without any locks, always return the physical file size, not the logical file size. check-in: 4016b422 user: drh tags: trunk
17:38
Be sure to release all wal-index locks before closing the wal-index. check-in: b15b67fa user: drh tags: trunk
17:20
Relax an over-zealous assert() in sqlite3WalUndo(). check-in: 8f9d22d5 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/wal.c.

557
558
559
560
561
562
563













564
565
566
567
568
569
570
...
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
...
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
    hdr.iCheck2 = 3;
  }

finished:
  walIndexWriteHdr(pWal, &hdr);
  return rc;
}














/* 
** 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
** figure out the name of the log file to open. If the log file does not 
** exist it is created by this call.
**
................................................................................
  /* Open file handle on the write-ahead log file. */
  if( rc==SQLITE_OK ){
    flags = (SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_MAIN_JOURNAL);
    rc = sqlite3OsOpen(pVfs, zWal, pRet->pFd, flags, &flags);
  }

  if( rc!=SQLITE_OK ){
    if( pRet->pWIndex ) pVfs->xShmClose(pVfs, pRet->pWIndex, 0);
    sqlite3OsClose(pRet->pFd);
    sqlite3_free(pRet);
  }else{
    *ppWal = pRet;
  }
  return rc;
}
................................................................................
      rc = walCheckpoint(pWal, pFd, sync_flags, nBuf, zBuf);
      if( rc==SQLITE_OK ){
        isDelete = 1;
      }
      walIndexUnmap(pWal);
    }

    pWal->pVfs->xShmClose(pWal->pVfs, pWal->pWIndex, isDelete);
    sqlite3OsClose(pWal->pFd);
    if( isDelete ){
      sqlite3OsDelete(pWal->pVfs, pWal->zName, 0);
    }
    sqlite3_free(pWal);
  }
  return rc;







>
>
>
>
>
>
>
>
>
>
>
>
>







 







|







 







|







557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
...
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
...
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
    hdr.iCheck2 = 3;
  }

finished:
  walIndexWriteHdr(pWal, &hdr);
  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
** figure out the name of the log file to open. If the log file does not 
** exist it is created by this call.
**
................................................................................
  /* Open file handle on the write-ahead log file. */
  if( rc==SQLITE_OK ){
    flags = (SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_MAIN_JOURNAL);
    rc = sqlite3OsOpen(pVfs, zWal, pRet->pFd, flags, &flags);
  }

  if( rc!=SQLITE_OK ){
    walIndexClose(pRet);
    sqlite3OsClose(pRet->pFd);
    sqlite3_free(pRet);
  }else{
    *ppWal = pRet;
  }
  return rc;
}
................................................................................
      rc = walCheckpoint(pWal, pFd, sync_flags, nBuf, zBuf);
      if( rc==SQLITE_OK ){
        isDelete = 1;
      }
      walIndexUnmap(pWal);
    }

    walIndexClose(pWal);
    sqlite3OsClose(pWal->pFd);
    if( isDelete ){
      sqlite3OsDelete(pWal->pVfs, pWal->zName, 0);
    }
    sqlite3_free(pWal);
  }
  return rc;