From: drh Date: Fri, 30 Apr 2010 15:54:46 +0000 (+0000) Subject: Fix a couple uninitialized variables in the xShmLock method of the unix VFS. X-Git-Tag: version-3.7.2~455^2~24 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d749084ad01242f87a867e5eb6e6e712bb326234;p=thirdparty%2Fsqlite.git Fix a couple uninitialized variables in the xShmLock method of the unix VFS. Improved debugging logic for xShmLock. FossilOrigin-Name: 69567c5fca9e30b7660e6f56350be929c3890d7e --- diff --git a/manifest b/manifest index d2b1cdb977..a8c76e2fb4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,8 @@ -C When\sclosing\sa\sWAL\sconnection,\sattempt\san\sexclusive\slock\son\sthe\sdatabase\sfile.\sIf\sthe\slock\sis\sobtained,\scheckpoint\sthe\sdatabase\sand\sdelete\sthe\swal\sand\swal-index\sfiles. -D 2010-04-30T15:49:28 +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +C Fix\sa\scouple\suninitialized\svariables\sin\sthe\sxShmLock\smethod\sof\sthe\sunix\sVFS.\nImproved\sdebugging\slogic\sfor\sxShmLock. +D 2010-04-30T15:54:47 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in d83a0ffef3dcbfb08b410a6c6dd6c009ec9167fb F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -150,7 +153,7 @@ F src/os.c 8bc63cf91e9802e2b807198e54e50227fa889306 F src/os.h 534b082c3cb349ad05fa6fa0b06087e022af282c F src/os_common.h 0d6ee583b6ee3185eb9d951f890c6dd03021a08d F src/os_os2.c 8ad77a418630d7dee91d1bb04f79c2096301d3a0 -F src/os_unix.c b2322d8fb389b4bc7834b1596bd8afac776a2f20 +F src/os_unix.c 7d10d3a8b4f3e0c7bde874ca7e488ea95b7cae35 F src/os_win.c a8fc01d8483be472e495793c01064fd87e56a5c1 F src/pager.c 434f9751fc2dfc11ade004282deda5f8560bcba2 F src/pager.h 934b598583a9d936bb13c37d62a2fe68ac48781c @@ -808,7 +811,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 837d82a92977cbfa0963411daf8160d286a7ed32 -R 3059f2f53adc88a1128c0bd66d3f0bb8 -U dan -Z 901b5f2ba561b4eab874813e39c862c1 +P c05e7dca172719f33e245c08d0c0e8ab47e5a537 +R 948b3a20fa291178488b4491978dd814 +U drh +Z 0b83af1d29a8669f0e45a2c764ca0612 +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQFL2v1KoxKgR168RlERAtTvAJ9anChtmXUlkLMCUv41sdV2i+tOhgCfd+Pd +kBX8Xzf3zeWR2SKzYU3eb8s= +=dWTT +-----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 108eb3175d..021b3496c3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c05e7dca172719f33e245c08d0c0e8ab47e5a537 \ No newline at end of file +69567c5fca9e30b7660e6f56350be929c3890d7e \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 006b0d182d..2af4f5a093 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -4716,6 +4716,7 @@ static int unixShmSystemLock( f.l_whence = SEEK_SET; if( (lockMask & UNIX_SHM_MUTEX)!=0 && lockType!=F_UNLCK ){ lockOp = F_SETLKW; + OSTRACE(("SHM-LOCK requesting blocking lock\n")); }else{ lockOp = F_SETLK; } @@ -4768,7 +4769,7 @@ static int unixShmSystemLock( OSTRACE(("write-lock failed")); } } - OSTRACE((" - change requested %s - afterwards %s,%s\n", + OSTRACE((" - change requested %s - afterwards %s:%s\n", unixShmLockString(lockMask), unixShmLockString(pFile->sharedMask), unixShmLockString(pFile->exclMask))); @@ -4794,6 +4795,7 @@ static int unixShmUnlock( assert( sqlite3_mutex_held(pFile->mutex) ); /* Compute locks held by sibling connections */ + allMask = 0; for(pX=pFile->pFirst; pX; pX=pX->pNext){ if( pX==p ) continue; assert( (pX->exclMask & (p->exclMask|p->sharedMask))==0 ); @@ -4834,6 +4836,7 @@ static int unixShmSharedLock( ** If any sibling already holds an exclusive lock, go ahead and return ** SQLITE_BUSY. */ + allShared = 0; for(pX=pFile->pFirst; pX; pX=pX->pNext){ if( pX==p ) continue; if( (pX->exclMask & readMask)!=0 ) return SQLITE_BUSY; @@ -5004,12 +5007,13 @@ static int unixShmOpen( if( unixShmSystemLock(pFile, F_WRLCK, UNIX_SHM_DMS)==SQLITE_OK ){ if( ftruncate(pFile->h, 0) ){ rc = SQLITE_IOERR; - goto shm_open_err; } } - rc = unixShmSystemLock(pFile, F_RDLCK, UNIX_SHM_DMS); - if( rc ) goto shm_open_err; + if( rc==SQLITE_OK ){ + rc = unixShmSystemLock(pFile, F_RDLCK, UNIX_SHM_DMS); + } unixShmSystemLock(pFile, F_UNLCK, UNIX_SHM_MUTEX); + if( rc ) goto shm_open_err; } /* Make the new connection a child of the unixShmFile */ @@ -5201,10 +5205,14 @@ static int unixShmLock( || desiredLock==p->lockState || (desiredLock==SQLITE_SHM_READ && p->lockState==SQLITE_SHM_READ_FULL) ){ + OSTRACE(("SHM-LOCK shmid-%d, pid-%d request %d and got %d\n", + p->id, getpid(), desiredLock, p->lockState)); if( pGotLock ) *pGotLock = p->lockState; return SQLITE_OK; } + OSTRACE(("SHM-LOCK shmid-%d, pid-%d request %d->%d\n", + p->id, getpid(), p->lockState, desiredLock)); sqlite3_mutex_enter(pFile->mutex); switch( desiredLock ){ case SQLITE_SHM_UNLOCK: { @@ -5293,6 +5301,7 @@ static int unixShmLock( } } sqlite3_mutex_leave(pFile->mutex); + OSTRACE(("SHM-LOCK shmid-%d, pid-%d got %d\n", p->id,getpid(),p->lockState)); if( pGotLock ) *pGotLock = p->lockState; return rc; }