/ Check-in [5f4437c0]
Login

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

Overview
Comment:Merge accidental fork.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | experimental-mmap
Files: files | file ages | folders
SHA1: 5f4437c0e35c8aa740515aac3e81e0146716d2bb
User & Date: dan 2013-04-01 17:58:10
Context
2013-04-01
18:15
In windows, round down the size of the memory mapped region to the next smaller multiple of the page size. check-in: 0e44ed1b user: drh tags: experimental-mmap
17:58
Merge accidental fork. check-in: 5f4437c0 user: dan tags: experimental-mmap
17:56
Attempt to emulate mremap() on non-Linux systems by allocating a second mapping immediately following the first in virtual memory. check-in: 4d67433d user: dan tags: experimental-mmap
17:56
Bug fix in the winMapfile() subroutine: Be sure to record the map object handle in the sqlite3_file object. check-in: ee4d188e user: drh tags: experimental-mmap
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_win.c.

  3551   3551   ** SQLITE_OK is returned if no error occurs (even if the mapping is not
  3552   3552   ** recreated as a result of outstanding references) or an SQLite error
  3553   3553   ** code otherwise.
  3554   3554   */
  3555   3555   static int winMapfile(winFile *pFd, sqlite3_int64 nByte){
  3556   3556     sqlite3_int64 nMap = nByte;
  3557   3557     int rc;
  3558         -  HANDLE hMap = NULL;             /* New mapping handle */
  3559   3558   
  3560   3559     assert( nMap>=0 || pFd->nFetchOut==0 );
  3561   3560     if( pFd->nFetchOut>0 ) return SQLITE_OK;
  3562   3561   
  3563   3562     if( nMap<0 ){
  3564   3563       rc = winFileSize((sqlite3_file*)pFd, &nMap);
  3565   3564       if( rc ){
................................................................................
  3580   3579   
  3581   3580       winUnmapfile(pFd);
  3582   3581       if( (pFd->ctrlFlags & WINFILE_RDONLY)==0 ){
  3583   3582         protect = PAGE_READWRITE;
  3584   3583         flags |= FILE_MAP_WRITE;
  3585   3584       }
  3586   3585   #if SQLITE_OS_WINRT
  3587         -    hMap = osCreateFileMappingFromApp(pFd->h, NULL, protect, nMap, NULL);
         3586  +    pFd->hMap = osCreateFileMappingFromApp(pFd->h, NULL, protect, nMap, NULL);
  3588   3587   #elif defined(SQLITE_WIN32_HAS_WIDE)
  3589         -    hMap = osCreateFileMappingW(pFd->h, NULL, protect,
         3588  +    pFd->hMap = osCreateFileMappingW(pFd->h, NULL, protect,
  3590   3589                                   (DWORD)((nMap>>32) & 0xffffffff),
  3591   3590                                   (DWORD)(nMap & 0xffffffff), NULL);
  3592   3591   #elif defined(SQLITE_WIN32_HAS_ANSI)
  3593         -    hMap = osCreateFileMappingA(pFd->h, NULL, protect,
         3592  +    pFd->hMap = osCreateFileMappingA(pFd->h, NULL, protect,
  3594   3593                                   (DWORD)((nMap>>32) & 0xffffffff),
  3595   3594                                   (DWORD)(nMap & 0xffffffff), NULL);
  3596   3595   #endif
  3597         -    if( hMap==NULL ){
         3596  +    if( pFd->hMap==NULL ){
  3598   3597         pFd->lastErrno = osGetLastError();
  3599   3598         rc = winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno,
  3600   3599                          "winMapfile", pFd->zPath);
  3601   3600         /* Log the error, but continue normal operation using xRead/xWrite */
  3602   3601         return SQLITE_OK;
  3603   3602       }
  3604   3603       assert( (nNewRnd % winSysInfo.dwPageSize)==0 );
  3605   3604   #if SQLITE_OS_WINRT
  3606         -    pNew = osMapViewOfFileFromApp(hMap, flags, 0, nMap);
         3605  +    pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, nMap);
  3607   3606   #else
  3608         -    pNew = osMapViewOfFile(hMap, flags, 0, 0, (SIZE_T)nMap);
         3607  +    pNew = osMapViewOfFile(pFd->hMap, flags, 0, 0, (SIZE_T)nMap);
  3609   3608   #endif
  3610   3609       if( pNew==NULL ){
  3611         -      osCloseHandle(hMap);
  3612         -      hMap = NULL;
         3610  +      osCloseHandle(pFd->hMap);
         3611  +      pFd->hMap = NULL;
  3613   3612         pFd->lastErrno = osGetLastError();
  3614   3613         winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno,
  3615   3614                     "winMapfile", pFd->zPath);
  3616   3615         return SQLITE_OK;
  3617   3616       }
  3618   3617       pFd->pMapRegion = pNew;
  3619   3618       pFd->mmapSize = nMap;