Ignore:
Timestamp:
Jul 7, 2011, 1:44:25 PM (14 years ago)
Author:
dmik
Message:

kernel32: Fixed a regression in r21655 that caused crashes in DOSCALL1 when writing to memory mapped files. The wrong code path would incorrectly invalidate memory pages on each write. Closes Java ticket 129.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/hmfile.cpp

    r21655 r21667  
    556556      dprintf(("Flush memory maps to disk before reading!!"));
    557557      map->flushView(MMAP_FLUSHVIEW_ALL, curpos, nNumberOfBytesToRead);
     558      map->Release();
    558559  }
    559560
     
    644645  else lpRealBuf = (LPVOID)lpBuffer;
    645646
    646   //If this file is also used in a memory map somewhere, then we need
    647   //to tell the map to flush all modified contents to disk right NOW
    648   DWORD curfilepos;
    649   map = Win32MemMap::findMapByFile(pHMHandleData->hWin32Handle);
    650   if(map && map->getFileHandle() != pHMHandleData->hWin32Handle) {
    651       curfilepos = SetFilePointer(pHMHandleData, 0, NULL, FILE_CURRENT);
    652 
    653       dprintf(("Flush memory maps to disk before writing!!"));
    654       map->flushView(MMAP_FLUSHVIEW_ALL, curfilepos, nNumberOfBytesToWrite);
    655   }
    656 
    657647  if(pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) {
    658648    dprintf(("ERROR: Overlapped IO not yet implememented!!"));
     
    665655//  }
    666656
    667   if(map && bRC) {
    668       dprintf(("Invalidate memory map after file writing!!"));
    669       map->invalidatePages(curfilepos, *lpNumberOfBytesWritten);
     657  if (bRC) {
     658    //If this file is also used in a memory map somewhere, then we need
     659    //to invalidate memory pages that we just wrote
     660    DWORD curfilepos;
     661    map = Win32MemMap::findMapByFile(pHMHandleData->hWin32Handle);
     662    if(map) {
     663        curfilepos = SetFilePointer(pHMHandleData, 0, NULL, FILE_CURRENT);
     664
     665        dprintf(("Invalidate memory map after file writing!!"));
     666        map->invalidatePages(curfilepos, *lpNumberOfBytesWritten);
     667        map->Release();
     668    }
    670669  }
    671670
Note: See TracChangeset for help on using the changeset viewer.