Index: src/os_win.c ================================================================== --- src/os_win.c +++ src/os_win.c @@ -3893,11 +3893,11 @@ ** ** If the DMS cannot be locked because this is a readonly_shm=1 ** connection and no other process already holds a lock, return ** SQLITE_READONLY_CANTINIT and set pShmNode->isUnlocked=1. */ -static int winLockSharedMemory(winFile *pDbFd, winShmNode *pShmNode){ +static int winLockSharedMemory(winShmNode *pShmNode){ int lockType; int rc = SQLITE_OK; /* Use ReadFile/WriteFile to determine the locks other processes are ** holding on the DMS byte. If it indicates that another process is @@ -4012,21 +4012,21 @@ } if( rc2!=SQLITE_OK ){ rc2 = winOpen(pDbFd->pVfs, pShmNode->zFilename, (sqlite3_file*)&pShmNode->hFile, - SQLITE_OPEN_WAL|SQLITE_OPEN_READONLY|SQLITE_OPEN_CREATE, + SQLITE_OPEN_WAL|SQLITE_OPEN_READONLY, 0); if( rc2!=SQLITE_OK ){ rc = winLogError(SQLITE_CANTOPEN_BKPT, osGetLastError(), "winOpenShm", pShmNode->zFilename); goto shm_open_err; } pShmNode->isReadonly = 1; } - rc = winLockSharedMemory(pDbFd, pShmNode); + rc = winLockSharedMemory(pShmNode); if( rc!=SQLITE_OK && rc!=SQLITE_READONLY_CANTINIT ) goto shm_open_err; } /* Make the new connection a child of the winShmNode */ p->pShmNode = pShmNode; @@ -4046,11 +4046,11 @@ */ sqlite3_mutex_enter(pShmNode->mutex); p->pNext = pShmNode->pFirst; pShmNode->pFirst = p; sqlite3_mutex_leave(pShmNode->mutex); - return SQLITE_OK; + return rc; /* Jump here on any error */ shm_open_err: winShmSystemLock(pShmNode, WINSHM_UNLCK, WIN_SHM_DMS, 1); winShmPurge(pDbFd->pVfs, 0); /* This call frees pShmNode if required */ @@ -4263,11 +4263,11 @@ } pShmNode = pShm->pShmNode; sqlite3_mutex_enter(pShmNode->mutex); if( pShmNode->isUnlocked ){ - rc = winLockSharedMemory(pDbFd, pShmNode); + rc = winLockSharedMemory(pShmNode); if( rc!=SQLITE_OK ) goto shmpage_out; pShmNode->isUnlocked = 0; } assert( szRegion==pShmNode->szRegion || pShmNode->nRegion==0 );