/ Check-in [5ed168c4]
Login

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

Overview
Comment:Changes to 3.5.9 proposed by Rob Stoddard.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | branch-3.5.9
Files: files | file ages | folders
SHA1: 5ed168c48ee4db25e5a3814c79898790931e1e70
User & Date: drh 2010-01-29 19:46:07
Context
2010-01-29
19:50
Additional changes suggested by Rob Stoddard. Closed-Leaf check-in: 228b8ad9 user: drh tags: branch-3.5.9
19:46
Changes to 3.5.9 proposed by Rob Stoddard. check-in: 5ed168c4 user: drh tags: branch-3.5.9
2008-05-14
16:18
Version 3.5.9 (CVS 5131) check-in: b6129f4c user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pager.c.

  1268   1268   ** Clear the in-memory cache.  This routine
  1269   1269   ** sets the state of the pager back to what it was when it was first
  1270   1270   ** opened.  Any outstanding pages are invalidated and subsequent attempts
  1271   1271   ** to access those pages will likely result in a coredump.
  1272   1272   */
  1273   1273   static void pager_reset(Pager *pPager){
  1274   1274     PgHdr *pPg, *pNext;
         1275  +#ifndef SQLITE_MUTEX_NOOP
         1276  +  sqlite3_mutex *mutex;
         1277  +#endif
  1275   1278     if( pPager->errCode ) return;
         1279  +#ifndef SQLITE_MUTEX_NOOP
         1280  +  mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM2);
         1281  +  sqlite3_mutex_enter(mutex);
         1282  +#endif
         1283  +
  1276   1284     for(pPg=pPager->pAll; pPg; pPg=pNext){
  1277   1285       IOTRACE(("PGFREE %p %d\n", pPager, pPg->pgno));
  1278   1286       PAGER_INCR(sqlite3_pager_pgfree_count);
  1279   1287       pNext = pPg->pNextAll;
  1280   1288       lruListRemove(pPg);
  1281   1289       sqlite3_free(pPg->pData);
  1282   1290       sqlite3_free(pPg);
................................................................................
  1288   1296     pPager->pAll = 0;
  1289   1297     pPager->pDirty = 0;
  1290   1298     pPager->nHash = 0;
  1291   1299     sqlite3_free(pPager->aHash);
  1292   1300     pPager->nPage = 0;
  1293   1301     pPager->aHash = 0;
  1294   1302     pPager->nRef = 0;
         1303  +  sqlite3_mutex_leave(mutex);
  1295   1304   }
  1296   1305   
  1297   1306   /*
  1298   1307   ** Unlock the database file. 
  1299   1308   **
  1300   1309   ** If the pager is currently in error state, discard the contents of 
  1301   1310   ** the cache and reset the Pager structure internal state. If there is
................................................................................
  2632   2641   ** that page and guarantee a subsequent segfault, it seems better
  2633   2642   ** to zero it and hope that we error out sanely.
  2634   2643   */
  2635   2644   static void pager_truncate_cache(Pager *pPager){
  2636   2645     PgHdr *pPg;
  2637   2646     PgHdr **ppPg;
  2638   2647     int dbSize = pPager->dbSize;
         2648  +#ifndef SQLITE_MUTEX_NOOP
         2649  +  sqlite3_mutex *mutex;
         2650  +  mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM2);
         2651  +#endif
         2652  +  sqlite3_mutex_enter(mutex);
  2639   2653   
  2640   2654     ppPg = &pPager->pAll;
  2641   2655     while( (pPg = *ppPg)!=0 ){
  2642   2656       if( pPg->pgno<=dbSize ){
  2643   2657         ppPg = &pPg->pNextAll;
  2644   2658       }else if( pPg->nRef>0 ){
  2645   2659         memset(PGHDR_TO_DATA(pPg), 0, pPager->pageSize);
................................................................................
  2651   2665         unlinkPage(pPg);
  2652   2666         makeClean(pPg);
  2653   2667         sqlite3_free(pPg->pData);
  2654   2668         sqlite3_free(pPg);
  2655   2669         pPager->nPage--;
  2656   2670       }
  2657   2671     }
         2672  +  sqlite3_mutex_leave(mutex);
  2658   2673   }
  2659   2674   
  2660   2675   /*
  2661   2676   ** Try to obtain a lock on a file.  Invoke the busy callback if the lock
  2662   2677   ** is currently not available.  Repeat until the busy callback returns
  2663   2678   ** false or until the lock succeeds.
  2664   2679   **