From: drh Date: Sat, 30 Jan 2010 22:28:46 +0000 (+0000) Subject: Always hold the MEM2 mutex when initially marking a pager as in use by its X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5b6532a272385a7ee7137c81b91baf9d019b25ee;p=thirdparty%2Fsqlite.git Always hold the MEM2 mutex when initially marking a pager as in use by its database connection. FossilOrigin-Name: 622c17177af6851fec11bdec8fb6246c13135b2f --- diff --git a/manifest b/manifest index ef8711913d..522a2abc1e 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Avoid\sa\srace\scondition\sin\sthe\ssqlite3_release_memory()\slogic\swithin\spager.c. -D 2010-01-30T19:17:07 +C Always\shold\sthe\sMEM2\smutex\swhen\sinitially\smarking\sa\spager\sas\sin\suse\sby\sits\ndatabase\sconnection. +D 2010-01-30T22:28:47 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7 F Makefile.in 79aeba12300a54903f1b1257c1e7c190234045dd F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -124,7 +124,7 @@ F src/os_common.h e8b748b2f2ecc8a498e50bfe5d8721f189c19d2a F src/os_os2.c 0c3a5802bc4fdb7cb5f66771552b081c4e48a216 F src/os_unix.c a810e2aefdaddacf479407f76f8f4ca381d231b2 F src/os_win.c 3a60bddd07ea6f8adb2314dd5996ac97b988f403 -F src/pager.c 3b7e5e4e250deac18b1a0a9ef651debc0690d6ae +F src/pager.c 1f77fc8d4ca6c8119c46e578c6595b8bc58b2966 F src/pager.h 4f051fd856de6fd3c19aef5f82eace54122b9173 F src/parse.y fc4bd35c6088901f7c8daead26c6fb11c87d22e7 F src/pragma.c 2e4bb2e76e48a32750529fdc4bfe86ac5f54e01b @@ -637,14 +637,14 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 -P 9d13acc4493ee8be9e6cbf887cd7876d6239b952 -R 25875cbaa3332e847212b49923ec3929 +P a718e6634795a48b5dd5c08833ab561e6381a62d +R ede77834150c4686fbce83c90fb93739 U drh -Z 2718af45d2ca11e075da3a339f4d03bc +Z 271b73fa90b6232af1206fcf2703ce9e -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFLZIW2oxKgR168RlERApuGAKCA4g/+5TbRsKOnLtfTD7whFywjuQCcDhRS -xtMVTORcy2iXShF+utiz32I= -=WeIu +iD8DBQFLZLKioxKgR168RlERArSqAJ0ZqE31rSrzcJl/uPoUKXMfOlFjNQCfVJZ0 +xM3NDDmzfB5aB8fx/vE9XOk= +=vAb3 -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 0f9415df4a..52f37c1238 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a718e6634795a48b5dd5c08833ab561e6381a62d \ No newline at end of file +622c17177af6851fec11bdec8fb6246c13135b2f \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index 9b0177fadc..5b186e02b5 100644 --- a/src/pager.c +++ b/src/pager.c @@ -519,13 +519,13 @@ static const unsigned char aJournalMagic[] = { */ #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT static void pagerEnter(Pager *p){ - p->iInUseDB++; - if( p->iInUseMM && p->iInUseDB==1 ){ + if( p->iInUseDB>0 ){ + p->iInUseDB++; + }else{ #ifndef SQLITE_MUTEX_NOOP sqlite3_mutex *mutex; mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM2); #endif - p->iInUseDB = 0; sqlite3_mutex_enter(mutex); assert( p->iInUseMM==0 ); p->iInUseDB = 1; @@ -3318,9 +3318,11 @@ int sqlite3PagerReleaseMemory(int nReq){ if( !pPg ) break; pPager = pPg->pPager; + assert( pPager->iInUseDB==0 ); savedBusy = pPager->pBusyHandler; pPager->pBusyHandler = 0; rc = pager_recycle(pPager, &pPg); + assert( pPager->iInUseDB==0 ); pPager->pBusyHandler = savedBusy; if( rc==SQLITE_OK ){ /* We've found a page to free. At this point the page has been