/ 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 Unified Diffs Ignore Whitespace Patch

Changes to src/os_win.c.

3556
3557
3558
3559
3560
3561
3562


3563

3564
3565
3566
3567
3568
3569
3570
  ** mapping (nNew bytes) may be greater than the size of the database file.
  ** If this is the case, extend the file on disk using ftruncate().  */
  assert( nNewRnd>0 || (flags & SQLITE_MREMAP_EXTEND)==0 );
  if( flags & SQLITE_MREMAP_EXTEND ){
    sqlite3_int64 oldSz;
    rc = winFileSize(id, &oldSz);
    if( rc==SQLITE_OK && nNewRnd>oldSz ){


      rc = winTruncate(id, nNewRnd);

    }
    if( rc!=SQLITE_OK ) return rc;
  }

  /* If we get this far, unmap any old mapping. */
  rc = winUnmap(id);
  if( rc!=SQLITE_OK ) return rc;







>
>
|
>







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

  /* If we get this far, unmap any old mapping. */
  rc = winUnmap(id);
  if( rc!=SQLITE_OK ) return rc;