Browse Source

Merge pull request #2589 from sipa/win32ldberr

Some win32-leveldb related fixes
0.8
Pieter Wuille 12 years ago
parent
commit
d2cefe1674
  1. 8
      src/leveldb/util/env_win.cc

8
src/leveldb/util/env_win.cc

@ -420,7 +420,7 @@ BOOL Win32RandomAccessFile::_Init( LPCWSTR path )
{ {
BOOL bRet = FALSE; BOOL bRet = FALSE;
if(!_hFile) if(!_hFile)
_hFile = ::CreateFileW(path,GENERIC_READ,0,NULL,OPEN_EXISTING, _hFile = ::CreateFileW(path,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS,NULL); FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS,NULL);
if(!_hFile || _hFile == INVALID_HANDLE_VALUE ) if(!_hFile || _hFile == INVALID_HANDLE_VALUE )
_hFile = NULL; _hFile = NULL;
@ -462,8 +462,8 @@ bool Win32MapFile::_UnmapCurrentRegion()
// Defer syncing this data until next Sync() call, if any // Defer syncing this data until next Sync() call, if any
_pending_sync = true; _pending_sync = true;
} }
UnmapViewOfFile(_base); if (!UnmapViewOfFile(_base) || !CloseHandle(_base_handle))
CloseHandle(_base_handle); result = false;
_file_offset += _limit - _base; _file_offset += _limit - _base;
_base = NULL; _base = NULL;
_base_handle = NULL; _base_handle = NULL;
@ -971,7 +971,7 @@ Status Win32Env::NewRandomAccessFile( const std::string& fname, RandomAccessFile
if(!pFile->isEnable()){ if(!pFile->isEnable()){
delete pFile; delete pFile;
*result = NULL; *result = NULL;
sRet = Status::IOError(path,"Could not create random access file."); sRet = Status::IOError(path, Win32::GetLastErrSz());
}else }else
*result = pFile; *result = pFile;
return sRet; return sRet;

Loading…
Cancel
Save