/ Check-in [8870c4cc]
Login

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

Overview
Comment:In the winMremap VFS function, unmap the region prior to attempting to truncate the file.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | experimental-mmap
Files: files | file ages | folders
SHA1: 8870c4cc6cda07154936644f7df25bd81d6ba38a
User & Date: mistachkin 2013-03-23 12:15:27
Context
2013-03-23
14:20
Fix a case where a checkpoint operation could write to an invalid part of a memory mapped region. check-in: 8dbe89d0 user: dan tags: experimental-mmap
12:15
In the winMremap VFS function, unmap the region prior to attempting to truncate the file. check-in: 8870c4cc user: mistachkin tags: experimental-mmap
10:09
Do not unmap the mapped file region in winTruncate as there may be outstanding pointers to it. check-in: f57a9c91 user: mistachkin tags: experimental-mmap
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_win.c.

  3556   3556     ** mapping (nNew bytes) may be greater than the size of the database file.
  3557   3557     ** If this is the case, extend the file on disk using ftruncate().  */
  3558   3558     assert( nNewRnd>0 || (flags & SQLITE_MREMAP_EXTEND)==0 );
  3559   3559     if( flags & SQLITE_MREMAP_EXTEND ){
  3560   3560       sqlite3_int64 oldSz;
  3561   3561       rc = winFileSize(id, &oldSz);
  3562   3562       if( rc==SQLITE_OK && nNewRnd>oldSz ){
  3563         -      rc = winTruncate(id, nNewRnd);
         3563  +      rc = winUnmap(id); /* Cannot truncate the file with an open mapping. */
         3564  +      if( rc==SQLITE_OK ){
         3565  +        rc = winTruncate(id, nNewRnd);
         3566  +      }
  3564   3567       }
  3565   3568       if( rc!=SQLITE_OK ) return rc;
  3566   3569     }
  3567   3570   
  3568   3571     /* If we get this far, unmap any old mapping. */
  3569   3572     rc = winUnmap(id);
  3570   3573     if( rc!=SQLITE_OK ) return rc;