diff options
author | danielk1977 <danielk1977@noemail.net> | 2009-03-30 07:39:35 +0000 |
---|---|---|
committer | danielk1977 <danielk1977@noemail.net> | 2009-03-30 07:39:35 +0000 |
commit | 64a54c52fe5ba8e7f373ececc7a9d2e68f352a08 (patch) | |
tree | 183bd2fb8879711e0cf2ce41f3e65a0774e2c74b | |
parent | f9e749cbbacb560cd1f265cf68a76addf3f3139a (diff) | |
download | sqlite-64a54c52fe5ba8e7f373ececc7a9d2e68f352a08.tar.gz sqlite-64a54c52fe5ba8e7f373ececc7a9d2e68f352a08.zip |
Another change related to (6401) and (6402): When an attempt to unlock a file fails in os_unix.c, close all files held open waiting for the unlock event anyway.
This prevents a file-descriptor leak when testing IO errors. (CVS 6406)
FossilOrigin-Name: 50fbcdea045f7d4266d9afa721616c720564aa93
-rw-r--r-- | manifest | 14 | ||||
-rw-r--r-- | manifest.uuid | 2 | ||||
-rw-r--r-- | src/os_unix.c | 50 |
3 files changed, 33 insertions, 33 deletions
@@ -1,5 +1,5 @@ -C Add\sa\scomment\sto\sthe\sdoubleToInt64()\sroutine\sthat\sexplains\swhy\sreturning\nminInt\sis\sin\sfact\scorrect\swhen\sit\sseems\slike\smaxInt\sshould\sbe\sreturned.\s(CVS\s6405) -D 2009-03-29T15:12:10 +C Another\schange\srelated\sto\s(6401)\sand\s(6402):\sWhen\san\sattempt\sto\sunlock\sa\sfile\sfails\sin\sos_unix.c,\sclose\sall\sfiles\sheld\sopen\swaiting\sfor\sthe\sunlock\sevent\sanyway.\n\sThis\sprevents\sa\sfile-descriptor\sleak\swhen\stesting\sIO\serrors.\s(CVS\s6406) +D 2009-03-30T07:39:35 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 583e87706abc3026960ed759aff6371faf84c211 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -141,7 +141,7 @@ F src/os.c c2aa4a7d8bb845222e5c37f56cde377b20c3b087 F src/os.h fa3f4aa0119ff721a2da4b47ffd74406ac864c05 F src/os_common.h 8c61457df58f1a4bd5f5adc3e90e01b37bf7afbc F src/os_os2.c bed77dc26e3a95ce4a204936b9a1ca6fe612fcc5 -F src/os_unix.c b62e660f82f4aa37d68ff4ffb11673ee4c75e1c9 +F src/os_unix.c 5d667f24615043c937a138faaed5f3e93b8619b0 F src/os_win.c 40636702058ed4dcd35d68151bfab56d4997cdc1 F src/pager.c 7a2b4b118708de09e580de66d46e51c1b655f76a F src/pager.h 0c9f3520c00d8a3b8e792ca56c9a11b6b02b4b0f @@ -711,7 +711,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e -P b601a57582051184baa37b807b1e18db93313e13 -R b24c431aeaa41c90ffe92c8a76f50df3 -U drh -Z a18eb87f581c8e08f864572471035b43 +P 7f3be3608542bbc6ac7916e5c3a5436e5f0a552e +R a9bdb3adde6598714edefb4405572e3f +U danielk1977 +Z d546563cba82beaa0b71a6d7a5a8a700 diff --git a/manifest.uuid b/manifest.uuid index 4208d06b9..998bf4b2e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7f3be3608542bbc6ac7916e5c3a5436e5f0a552e
\ No newline at end of file +50fbcdea045f7d4266d9afa721616c720564aa93
\ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index ddf7b2212..719f16c87 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -43,7 +43,7 @@ ** * Definitions of sqlite3_vfs objects for all locking methods ** plus implementations of sqlite3_os_init() and sqlite3_os_end(). ** -** $Id: os_unix.c,v 1.247 2009/03/28 23:47:11 drh Exp $ +** $Id: os_unix.c,v 1.248 2009/03/30 07:39:35 danielk1977 Exp $ */ #include "sqliteInt.h" #if SQLITE_OS_UNIX /* This file is used on unix only */ @@ -1459,6 +1459,7 @@ static int unixUnlock(sqlite3_file *id, int locktype){ } if( locktype==NO_LOCK ){ struct unixOpenCnt *pOpen; + int rc2 = SQLITE_OK; /* Decrement the shared lock counter. Release the lock using an ** OS call only when all threads in this same process have released @@ -1480,10 +1481,8 @@ static int unixUnlock(sqlite3_file *id, int locktype){ if( IS_LOCK_ERROR(rc) ){ pFile->lastErrno = tErrno; } - pLock->cnt = 1; pLock->locktype = NO_LOCK; pFile->locktype = NO_LOCK; - goto end_unlock; } } @@ -1491,30 +1490,31 @@ static int unixUnlock(sqlite3_file *id, int locktype){ ** count reaches zero, close any other file descriptors whose close ** was deferred because of outstanding locks. */ - if( rc==SQLITE_OK ){ - pOpen = pFile->pOpen; - pOpen->nLock--; - assert( pOpen->nLock>=0 ); - if( pOpen->nLock==0 && pOpen->nPending>0 ){ - int i; - for(i=0; i<pOpen->nPending; i++){ - /* close pending fds, but if closing fails don't free the array - ** assign -1 to the successfully closed descriptors and record the - ** error. The next attempt to unlock will try again. */ - if( pOpen->aPending[i] < 0 ) continue; - if( close(pOpen->aPending[i]) ){ - pFile->lastErrno = errno; - rc = SQLITE_IOERR_CLOSE; - }else{ - pOpen->aPending[i] = -1; - } - } - if( rc==SQLITE_OK ){ - sqlite3_free(pOpen->aPending); - pOpen->nPending = 0; - pOpen->aPending = 0; + pOpen = pFile->pOpen; + pOpen->nLock--; + assert( pOpen->nLock>=0 ); + if( pOpen->nLock==0 && pOpen->nPending>0 ){ + int i; + for(i=0; i<pOpen->nPending; i++){ + /* close pending fds, but if closing fails don't free the array + ** assign -1 to the successfully closed descriptors and record the + ** error. The next attempt to unlock will try again. */ + if( pOpen->aPending[i] < 0 ) continue; + if( close(pOpen->aPending[i]) ){ + pFile->lastErrno = errno; + rc2 = SQLITE_IOERR_CLOSE; + }else{ + pOpen->aPending[i] = -1; } } + if( rc2==SQLITE_OK ){ + sqlite3_free(pOpen->aPending); + pOpen->nPending = 0; + pOpen->aPending = 0; + } + } + if( rc==SQLITE_OK ){ + rc = rc2; } } |