/ Check-in [3a91be97]
Login
Overview
Comment:Corrections to Win32 lock detection for SHM files.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | readonly-wal-recovery
Files: files | file ages | folders
SHA3-256:3a91be975daee65c3e1199855613066015d5df8ad44ababdef31d1c698b5e746
User & Date: mistachkin 2017-11-09 18:21:51
Context
2017-11-09
18:53
Further corrections to read-only SHM file handling on Win32. check-in: 43c31170 user: mistachkin tags: readonly-wal-recovery
18:21
Corrections to Win32 lock detection for SHM files. check-in: 3a91be97 user: mistachkin tags: readonly-wal-recovery
17:29
Corrections to the Win32 porting changes on this branch. check-in: 0b26a5a2 user: mistachkin tags: readonly-wal-recovery
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/os_win.c.

2101
2102
2103
2104
2105
2106
2107

2108
2109
2110
2111
2112
2113
2114
2115
....
3863
3864
3865
3866
3867
3868
3869

3870

3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
/*
** The "winIsLockingError" macro is used to determine if a particular I/O
** error code is due to file locking.  It must accept the error code DWORD
** as its only argument and should return non-zero if the error code is due
** to file locking.
*/
#if !defined(winIsLockingError)

#define winIsLockingError(a) (((a)==ERROR_LOCK_VIOLATION)       || \
                              ((a)==ERROR_IO_PENDING))
#endif

/*
** The "winIoerrCanRetry1" macro is used to determine if a particular I/O
** error code obtained via GetLastError() is eligible to be retried.  It
** must accept the error code DWORD as its only argument and should return
................................................................................
#else
  memset(&overlapped, 0, sizeof(OVERLAPPED));
  overlapped.Offset = (LONG)(offset & 0xffffffff);
  overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);
  pOverlapped = &overlapped;
#endif
  if( !osWriteFile(pFile->h, &notUsed1, 1, &notUsed2, pOverlapped) ){

    if( !osReadFile(pFile->h, &notUsed1, 1, &notUsed2, pOverlapped) ){

      if( winIsLockingError(osGetLastError()) ){
        *pLockType = WINSHM_WRLCK;
      }else{
        return SQLITE_IOERR_READ;
      }
    }else{
      if( winIsLockingError(osGetLastError()) ){
        *pLockType = WINSHM_RDLCK;
      }else{
        return SQLITE_IOERR_WRITE;
      }
    }
  }else{
    *pLockType = WINSHM_UNLCK;







>
|







 







>

>
|





|







2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
....
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
/*
** The "winIsLockingError" macro is used to determine if a particular I/O
** error code is due to file locking.  It must accept the error code DWORD
** as its only argument and should return non-zero if the error code is due
** to file locking.
*/
#if !defined(winIsLockingError)
#define winIsLockingError(a) (((a)==ERROR_ACCESS_DENIED)        || \
                              ((a)==ERROR_LOCK_VIOLATION)       || \
                              ((a)==ERROR_IO_PENDING))
#endif

/*
** The "winIoerrCanRetry1" macro is used to determine if a particular I/O
** error code obtained via GetLastError() is eligible to be retried.  It
** must accept the error code DWORD as its only argument and should return
................................................................................
#else
  memset(&overlapped, 0, sizeof(OVERLAPPED));
  overlapped.Offset = (LONG)(offset & 0xffffffff);
  overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);
  pOverlapped = &overlapped;
#endif
  if( !osWriteFile(pFile->h, &notUsed1, 1, &notUsed2, pOverlapped) ){
    DWORD lastErrno = osGetLastError();
    if( !osReadFile(pFile->h, &notUsed1, 1, &notUsed2, pOverlapped) ){
      lastErrno = osGetLastError();
      if( winIsLockingError(lastErrno) ){
        *pLockType = WINSHM_WRLCK;
      }else{
        return SQLITE_IOERR_READ;
      }
    }else{
      if( winIsLockingError(lastErrno) ){
        *pLockType = WINSHM_RDLCK;
      }else{
        return SQLITE_IOERR_WRITE;
      }
    }
  }else{
    *pLockType = WINSHM_UNLCK;