SQLite

Check-in [9d13acc449]
Login

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

Overview
Comment:Remove all cache pages from the LRU list prior to removing the pager from the pager list when closing a pager.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | branch-3.5.9
Files: files | file ages | folders
SHA1: 9d13acc4493ee8be9e6cbf887cd7876d6239b952
User & Date: drh 2010-01-30 19:00:55.000
Context
2010-01-30
19:17
Avoid a race condition in the sqlite3_release_memory() logic within pager.c. (check-in: a718e66347 user: drh tags: branch-3.5.9)
19:00
Remove all cache pages from the LRU list prior to removing the pager from the pager list when closing a pager. (check-in: 9d13acc449 user: drh tags: branch-3.5.9)
18:22
Add additional pagerMutexHeld() macros to better verify the correct operation of pager.c. (check-in: c50e972f1b user: drh tags: branch-3.5.9)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/pager.c.
2752
2753
2754
2755
2756
2757
2758




2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
**
** This function always succeeds. If a transaction is active an attempt
** is made to roll it back. If an error occurs during the rollback 
** a hot journal may be left in the filesystem but no error is returned
** to the caller.
*/
int sqlite3PagerClose(Pager *pPager){




#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
  if( !MEMDB ){
#ifndef SQLITE_MUTEX_NOOP
    sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM2);
#endif
    sqlite3_mutex_enter(mutex);
    if( pPager->pPrev ){
      pPager->pPrev->pNext = pPager->pNext;
    }else{
      sqlite3PagerList = pPager->pNext;
    }
    if( pPager->pNext ){
      pPager->pNext->pPrev = pPager->pPrev;
    }
    sqlite3_mutex_leave(mutex);
    pPager->onPagerList = 0;
  }
#endif

  disable_simulated_io_errors();
  sqlite3FaultBeginBenign(-1);
  pPager->errCode = 0;
  pPager->exclusiveMode = 0;
  pager_reset(pPager);
  pagerUnlockAndRollback(pPager);
  enable_simulated_io_errors();
  sqlite3FaultEndBenign(-1);
  PAGERTRACE2("CLOSE %d\n", PAGERID(pPager));
  IOTRACE(("CLOSE %p\n", pPager))
  if( pPager->journalOpen ){
    sqlite3OsClose(pPager->jfd);







>
>
>
>


















<


<

<







2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780

2781
2782

2783

2784
2785
2786
2787
2788
2789
2790
**
** This function always succeeds. If a transaction is active an attempt
** is made to roll it back. If an error occurs during the rollback 
** a hot journal may be left in the filesystem but no error is returned
** to the caller.
*/
int sqlite3PagerClose(Pager *pPager){
  pagerEnter(pPager);
  pPager->errCode = 0;
  pager_reset(pPager);
  pagerLeave(pPager);
#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
  if( !MEMDB ){
#ifndef SQLITE_MUTEX_NOOP
    sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM2);
#endif
    sqlite3_mutex_enter(mutex);
    if( pPager->pPrev ){
      pPager->pPrev->pNext = pPager->pNext;
    }else{
      sqlite3PagerList = pPager->pNext;
    }
    if( pPager->pNext ){
      pPager->pNext->pPrev = pPager->pPrev;
    }
    sqlite3_mutex_leave(mutex);
    pPager->onPagerList = 0;
  }
#endif

  disable_simulated_io_errors();
  sqlite3FaultBeginBenign(-1);

  pPager->exclusiveMode = 0;

  pagerUnlockAndRollback(pPager);
  enable_simulated_io_errors();
  sqlite3FaultEndBenign(-1);
  PAGERTRACE2("CLOSE %d\n", PAGERID(pPager));
  IOTRACE(("CLOSE %p\n", pPager))
  if( pPager->journalOpen ){
    sqlite3OsClose(pPager->jfd);