1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-12 13:01:09 +03:00

Corrections to Win32 lock detection for SHM files.

FossilOrigin-Name: 3a91be975daee65c3e1199855613066015d5df8ad44ababdef31d1c698b5e746
This commit is contained in:
mistachkin
2017-11-09 18:21:51 +00:00
parent 8a6fa5d41c
commit a515065649
3 changed files with 13 additions and 10 deletions

View File

@@ -2105,7 +2105,8 @@ static int winIoerrRetryDelay = SQLITE_WIN32_IOERR_RETRY_DELAY;
** to file locking.
*/
#if !defined(winIsLockingError)
#define winIsLockingError(a) (((a)==ERROR_LOCK_VIOLATION) || \
#define winIsLockingError(a) (((a)==ERROR_ACCESS_DENIED) || \
((a)==ERROR_LOCK_VIOLATION) || \
((a)==ERROR_IO_PENDING))
#endif
@@ -3867,14 +3868,16 @@ static int winGetShmDmsLockType(
pOverlapped = &overlapped;
#endif
if( !osWriteFile(pFile->h, &notUsed1, 1, &notUsed2, pOverlapped) ){
DWORD lastErrno = osGetLastError();
if( !osReadFile(pFile->h, &notUsed1, 1, &notUsed2, pOverlapped) ){
if( winIsLockingError(osGetLastError()) ){
lastErrno = osGetLastError();
if( winIsLockingError(lastErrno) ){
*pLockType = WINSHM_WRLCK;
}else{
return SQLITE_IOERR_READ;
}
}else{
if( winIsLockingError(osGetLastError()) ){
if( winIsLockingError(lastErrno) ){
*pLockType = WINSHM_RDLCK;
}else{
return SQLITE_IOERR_WRITE;