Added fix for race conditions from os_unix.c; added saving of errno in two places.
FossilOrigin-Name: 13ed106c8c279422a6159e28c6887d13a88b7b8b
This commit is contained in:
parent
0668f5916e
commit
d5a724000b
14
manifest
14
manifest
@ -1,5 +1,5 @@
|
||||
C Fix\sa\srace\scondition\sin\sos_unix.c\sthat\smay\soccur\swhen\sone\sthread\sis\sopening\sa\sconnection\sto\sa\sshared-memory\sblock\sand\sanother\sis\seither\sclosing\sor\slocking\sthe\ssame\sshared-memory.
|
||||
D 2010-07-20T18:59:01
|
||||
C Added\sfix\sfor\srace\sconditions\sfrom\sos_unix.c;\sadded\ssaving\sof\serrno\sin\stwo\splaces.
|
||||
D 2010-07-20T20:23:38
|
||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||
F Makefile.in ec08dc838fd8110fe24c92e5130bcd91cbb1ff2e
|
||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||
@ -155,7 +155,7 @@ F src/os.h 9dbed8c2b9c1f2f2ebabc09e49829d4777c26bf9
|
||||
F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f
|
||||
F src/os_os2.c 665876d5eec7585226b0a1cf5e18098de2b2da19
|
||||
F src/os_unix.c 3109e0e5a0d5551bab2e8c7322b20a3b8b171248
|
||||
F src/os_win.c 61734aad7f50b28f3c76eb4b19b63472f6d825d9
|
||||
F src/os_win.c 1f8b0a1a5bcf6289e7754d0d3c16cec16d4c93ab
|
||||
F src/pager.c 78ca1e1f3315c8227431c403c04d791dccf242fb
|
||||
F src/pager.h 879fdde5a102d2f21a3135d6f647530b21c2796c
|
||||
F src/parse.y 220a11ac72e2c9dffbf4cbe5fe462f328bd8d884
|
||||
@ -837,7 +837,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||
P 92fe70dadde2eb551518d69ac2eaa6a0151d7dfe
|
||||
R df2a0b1fc90f9ee6b661361189db8cc8
|
||||
U dan
|
||||
Z 8ff12974b6f85e5f132c185f1bb718f5
|
||||
P 3b7330c19a5327322068e9460018fe0152b8ac87
|
||||
R f8111b94ec406976124441419b5d0d91
|
||||
U shaneh
|
||||
Z 1481f027c52f0315e6b182145a908af1
|
||||
|
@ -1 +1 @@
|
||||
3b7330c19a5327322068e9460018fe0152b8ac87
|
||||
13ed106c8c279422a6159e28c6887d13a88b7b8b
|
27
src/os_win.c
27
src/os_win.c
@ -1193,7 +1193,7 @@ static int winDeviceCharacteristics(sqlite3_file *id){
|
||||
**
|
||||
** winShmEnterMutex()
|
||||
** assert( winShmMutexHeld() );
|
||||
** winEnterLeave()
|
||||
** winShmLeaveMutex()
|
||||
*/
|
||||
static void winShmEnterMutex(void){
|
||||
sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
|
||||
@ -1320,13 +1320,19 @@ static int winShmSystemLock(
|
||||
}else{
|
||||
rc = LockFileEx(pFile->hFile.h, dwFlags, 0, nByte, 0, &ovlp);
|
||||
}
|
||||
rc = (rc!=0) ? SQLITE_OK : SQLITE_BUSY;
|
||||
|
||||
if( rc!= 0 ){
|
||||
rc = SQLITE_OK;
|
||||
}else{
|
||||
pFile->lastErrno = GetLastError();
|
||||
rc = SQLITE_BUSY;
|
||||
}
|
||||
|
||||
OSTRACE(("SHM-LOCK %d %s %s 0x%08lx\n",
|
||||
pFile->hFile.h,
|
||||
rc==SQLITE_OK ? "ok" : "failed",
|
||||
lockType==_SHM_UNLCK ? "UnlockFileEx" : "LockFileEx",
|
||||
GetLastError()));
|
||||
pFile->lastErrno));
|
||||
|
||||
return rc;
|
||||
}
|
||||
@ -1457,14 +1463,24 @@ static int winOpenSharedMemory(winFile *pDbFd){
|
||||
|
||||
/* Make the new connection a child of the winShmNode */
|
||||
p->pShmNode = pShmNode;
|
||||
p->pNext = pShmNode->pFirst;
|
||||
#ifdef SQLITE_DEBUG
|
||||
p->id = pShmNode->nextShmId++;
|
||||
#endif
|
||||
pShmNode->pFirst = p;
|
||||
pShmNode->nRef++;
|
||||
pDbFd->pShm = p;
|
||||
winShmLeaveMutex();
|
||||
|
||||
/* The reference count on pShmNode has already been incremented under
|
||||
** the cover of the winShmEnterMutex() mutex and the pointer from the
|
||||
** new (struct winShm) object to the pShmNode has been set. All that is
|
||||
** left to do is to link the new object into the linked list starting
|
||||
** at pShmNode->pFirst. This must be done while holding the pShmNode->mutex
|
||||
** mutex.
|
||||
*/
|
||||
sqlite3_mutex_enter(pShmNode->mutex);
|
||||
p->pNext = pShmNode->pFirst;
|
||||
pShmNode->pFirst = p;
|
||||
sqlite3_mutex_leave(pShmNode->mutex);
|
||||
return SQLITE_OK;
|
||||
|
||||
/* Jump here on any error */
|
||||
@ -2072,6 +2088,7 @@ static int winOpen(
|
||||
h, zName, dwDesiredAccess,
|
||||
h==INVALID_HANDLE_VALUE ? "failed" : "ok"));
|
||||
if( h==INVALID_HANDLE_VALUE ){
|
||||
pFile->lastErrno = GetLastError();
|
||||
free(zConverted);
|
||||
if( flags & SQLITE_OPEN_READWRITE ){
|
||||
return winOpen(pVfs, zName, id,
|
||||
|
Loading…
x
Reference in New Issue
Block a user