Do not hold the shared-memory mutex in os_unix.c if returning NULL.

FossilOrigin-Name: 9622dd468c8914262e9d8bd8dbca9e22ec6ee75c
This commit is contained in:
dan 2010-06-01 11:08:56 +00:00
parent e877296705
commit 72bcac9ca7
3 changed files with 33 additions and 29 deletions

View File

@ -1,5 +1,5 @@
C If\sthe\scheckpoint\sfails\sto\sobtain\san\sexclusive\slock\son\sone\sof\sthe\sread-lock\sbytes,\sdo\snot\sconsider\sthis\san\serror.
D 2010-06-01T10:44:29
C Do\snot\shold\sthe\sshared-memory\smutex\sin\sos_unix.c\sif\sreturning\sNULL.
D 2010-06-01T11:08:57
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in a5cad1f8f3e021356bfcc6c77dc16f6f1952bbc3
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -152,7 +152,7 @@ F src/os.c 1516984144e26734f97748f891f1a04f9e294c2e
F src/os.h 6f604986f0ef0ca288c2330b16051ff70b431e8c
F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f
F src/os_os2.c 665876d5eec7585226b0a1cf5e18098de2b2da19
F src/os_unix.c fe672ba65f15599b2940fd65613df59ce657ad3b
F src/os_unix.c 29dd06f4850672326765218e75cb49d7d618c254
F src/os_win.c f815403c51a2adad30244374c801dd7fd2734567
F src/pager.c acbef227bf158776449907c275c5d9332e4e52f9
F src/pager.h 76466c3a5af56943537f68b1f16567101a0cd1d0
@ -815,7 +815,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P cd5fbcbce8b55f24c0bf349b179c26e333ff7172
R ffdd8604f512c88d10a6de2f3e641d78
P 9e95e35728cf69a0ae50e774d7f6c71a41b17d97
R 67ccfc3b179b63c3e3b80e2b7e1142bd
U dan
Z ee37b099dcdd95ac7a6b81975abdbcbe
Z 560dece5b4a16dc5e0eff482c3f02a96

View File

@ -1 +1 @@
9e95e35728cf69a0ae50e774d7f6c71a41b17d97
9622dd468c8914262e9d8bd8dbca9e22ec6ee75c

View File

@ -3406,6 +3406,7 @@ static int unixShmClose(
*pp = p->pNext;
/* Free the connection p */
assert( p->hasMutexBuf==0 );
sqlite3_free(p);
pDbFd->pShm = 0;
sqlite3_mutex_leave(pShmNode->mutex);
@ -3464,6 +3465,27 @@ static int unixShmSize(
return rc;
}
/*
** Release the lock held on the shared memory segment to that other
** threads are free to resize it if necessary.
**
** If the lock is not currently held, this routine is a harmless no-op.
**
** If the shared-memory object is in lock state RECOVER, then we do not
** really want to release the lock, so in that case too, this routine
** is a no-op.
*/
static int unixShmRelease(sqlite3_file *fd){
unixFile *pDbFd = (unixFile*)fd;
unixShm *p = pDbFd->pShm;
if( p->hasMutexBuf ){
assert( sqlite3_mutex_notheld(p->pShmNode->mutex) );
sqlite3_mutex_leave(p->pShmNode->mutexBuf);
p->hasMutexBuf = 0;
}
return SQLITE_OK;
}
/*
** Map the shared storage into memory.
@ -3537,29 +3559,11 @@ static int unixShmGet(
*pNewMapSize = pShmNode->szMap;
*ppBuf = pShmNode->pMMapBuf;
sqlite3_mutex_leave(pShmNode->mutex);
return rc;
}
/*
** Release the lock held on the shared memory segment to that other
** threads are free to resize it if necessary.
**
** If the lock is not currently held, this routine is a harmless no-op.
**
** If the shared-memory object is in lock state RECOVER, then we do not
** really want to release the lock, so in that case too, this routine
** is a no-op.
*/
static int unixShmRelease(sqlite3_file *fd){
unixFile *pDbFd = (unixFile*)fd;
unixShm *p = pDbFd->pShm;
if( p->hasMutexBuf ){
assert( sqlite3_mutex_notheld(p->pShmNode->mutex) );
sqlite3_mutex_leave(p->pShmNode->mutexBuf);
p->hasMutexBuf = 0;
if( *ppBuf==0 ){
/* Do not hold the mutex if a NULL pointer is being returned. */
unixShmRelease(fd);
}
return SQLITE_OK;
return rc;
}