/ Check-in [0b26a5a2]
Login

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

Overview
Comment:Corrections to the Win32 porting changes on this branch.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | readonly-wal-recovery
Files: files | file ages | folders
SHA3-256: 0b26a5a26d700e20eea5ebbd620af0af6f2d61c652cfca5b8563267588cb2be6
User & Date: mistachkin 2017-11-09 17:29:18
Context
2017-11-09
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
17:29
Make it possible to use OSTRACE for multi-process testing. check-in: 0a7d416c user: mistachkin tags: readonly-wal-recovery
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_win.c.

  3891   3891   ** take it now. Return SQLITE_OK if successful, or an SQLite error
  3892   3892   ** code otherwise.
  3893   3893   **
  3894   3894   ** If the DMS cannot be locked because this is a readonly_shm=1
  3895   3895   ** connection and no other process already holds a lock, return
  3896   3896   ** SQLITE_READONLY_CANTINIT and set pShmNode->isUnlocked=1.
  3897   3897   */
  3898         -static int winLockSharedMemory(winFile *pDbFd, winShmNode *pShmNode){
         3898  +static int winLockSharedMemory(winShmNode *pShmNode){
  3899   3899     int lockType;
  3900   3900     int rc = SQLITE_OK;
  3901   3901   
  3902   3902     /* Use ReadFile/WriteFile to determine the locks other processes are
  3903   3903     ** holding on the DMS byte. If it indicates that another process is
  3904   3904     ** holding a SHARED lock, then this process may also take a SHARED
  3905   3905     ** lock and proceed with opening the *-shm file.
................................................................................
  4010   4010                       SQLITE_OPEN_WAL|SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE,
  4011   4011                       0);
  4012   4012       }
  4013   4013       if( rc2!=SQLITE_OK ){
  4014   4014         rc2 = winOpen(pDbFd->pVfs,
  4015   4015                       pShmNode->zFilename,
  4016   4016                       (sqlite3_file*)&pShmNode->hFile,
  4017         -                    SQLITE_OPEN_WAL|SQLITE_OPEN_READONLY|SQLITE_OPEN_CREATE,
         4017  +                    SQLITE_OPEN_WAL|SQLITE_OPEN_READONLY,
  4018   4018                       0);
  4019   4019         if( rc2!=SQLITE_OK ){
  4020   4020           rc = winLogError(SQLITE_CANTOPEN_BKPT, osGetLastError(),
  4021   4021                            "winOpenShm", pShmNode->zFilename);
  4022   4022           goto shm_open_err;
  4023   4023         }
  4024   4024         pShmNode->isReadonly = 1;
  4025   4025       }
  4026   4026   
  4027         -    rc = winLockSharedMemory(pDbFd, pShmNode);
         4027  +    rc = winLockSharedMemory(pShmNode);
  4028   4028       if( rc!=SQLITE_OK && rc!=SQLITE_READONLY_CANTINIT ) goto shm_open_err;
  4029   4029     }
  4030   4030   
  4031   4031     /* Make the new connection a child of the winShmNode */
  4032   4032     p->pShmNode = pShmNode;
  4033   4033   #if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)
  4034   4034     p->id = pShmNode->nextShmId++;
................................................................................
  4044   4044     ** at pShmNode->pFirst. This must be done while holding the pShmNode->mutex
  4045   4045     ** mutex.
  4046   4046     */
  4047   4047     sqlite3_mutex_enter(pShmNode->mutex);
  4048   4048     p->pNext = pShmNode->pFirst;
  4049   4049     pShmNode->pFirst = p;
  4050   4050     sqlite3_mutex_leave(pShmNode->mutex);
  4051         -  return SQLITE_OK;
         4051  +  return rc;
  4052   4052   
  4053   4053     /* Jump here on any error */
  4054   4054   shm_open_err:
  4055   4055     winShmSystemLock(pShmNode, WINSHM_UNLCK, WIN_SHM_DMS, 1);
  4056   4056     winShmPurge(pDbFd->pVfs, 0);      /* This call frees pShmNode if required */
  4057   4057     sqlite3_free(p);
  4058   4058     sqlite3_free(pNew);
................................................................................
  4261   4261       if( rc!=SQLITE_OK ) return rc;
  4262   4262       pShm = pDbFd->pShm;
  4263   4263     }
  4264   4264     pShmNode = pShm->pShmNode;
  4265   4265   
  4266   4266     sqlite3_mutex_enter(pShmNode->mutex);
  4267   4267     if( pShmNode->isUnlocked ){
  4268         -    rc = winLockSharedMemory(pDbFd, pShmNode);
         4268  +    rc = winLockSharedMemory(pShmNode);
  4269   4269       if( rc!=SQLITE_OK ) goto shmpage_out;
  4270   4270       pShmNode->isUnlocked = 0;
  4271   4271     }
  4272   4272     assert( szRegion==pShmNode->szRegion || pShmNode->nRegion==0 );
  4273   4273   
  4274   4274     if( pShmNode->nRegion<=iRegion ){
  4275   4275       struct ShmRegion *apNew;           /* New aRegion[] array */