]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Be sure to release any xShmLock locks held when closing an OTA handle.
authordan <dan@noemail.net>
Thu, 16 Apr 2015 18:49:53 +0000 (18:49 +0000)
committerdan <dan@noemail.net>
Thu, 16 Apr 2015 18:49:53 +0000 (18:49 +0000)
FossilOrigin-Name: d0fba72a47f73082ade40a732aab114bc8f6d83e

ext/ota/otaA.test
ext/ota/sqlite3ota.c
manifest
manifest.uuid

index c76609035a8e6cfa658a1d71fe928df74e58e9ef..bcc9a8b725a952ab95bd07204e9710b84aefcd9d 100644 (file)
@@ -31,6 +31,7 @@ set ota_sql {
 }
 
 do_test 1.0 {
+  db close
   forcedelete test.db ota.db
 
   sqlite3 db test.db
index 580840b36af65bfab0ca880ffba4d85423f8770d..552eadf0b17bb4290496f108b279625806dfd4dd 100644 (file)
@@ -629,6 +629,7 @@ static int otaMPrintfExec(sqlite3ota *p, sqlite3 *db, const char *zFmt, ...){
 static void *otaMalloc(sqlite3ota *p, int nByte){
   void *pRet = 0;
   if( p->rc==SQLITE_OK ){
+    assert( nByte>0 );
     pRet = sqlite3_malloc(nByte);
     if( pRet==0 ){
       p->rc = SQLITE_NOMEM;
@@ -2845,6 +2846,19 @@ sqlite3_int64 sqlite3ota_progress(sqlite3ota *pOta){
 **     file fail with SQLITE_INTERNAL errors.
 */
 
+static void otaUnlockShm(ota_file *p){
+  if( p->pOta ){
+    int (*xShmLock)(sqlite3_file*,int,int,int) = p->pReal->pMethods->xShmLock;
+    int i;
+    for(i=0; i<SQLITE_SHM_NLOCK;i++){
+      if( (1<<i) & p->pOta->mLock ){
+        xShmLock(p->pReal, i, 1, SQLITE_SHM_UNLOCK|SQLITE_SHM_EXCLUSIVE);
+      }
+    }
+    p->pOta->mLock = 0;
+  }
+}
+
 /*
 ** Close an ota file.
 */
@@ -2867,6 +2881,7 @@ static int otaVfsClose(sqlite3_file *pFile){
     for(pp=&p->pOtaVfs->pMain; *pp!=p; pp=&((*pp)->pMainNext));
     *pp = p->pMainNext;
     sqlite3_mutex_leave(p->pOtaVfs->mutex);
+    otaUnlockShm(p);
     p->pReal->pMethods->xShmUnmap(p->pReal, 0);
   }
 
@@ -3203,6 +3218,8 @@ static int otaVfsShmUnmap(sqlite3_file *pFile, int delFlag){
   if( eStage==OTA_STAGE_OAL || eStage==OTA_STAGE_MOVE ){
     /* no-op */
   }else{
+    /* Release the checkpointer and writer locks */
+    otaUnlockShm(p);
     rc = p->pReal->pMethods->xShmUnmap(p->pReal, delFlag);
   }
   return rc;
index 74fa58f17afdcbf80e540e33e802f4dcd6e5b34b..ef669d784fbbd017965fa03b12f0f00411c32714 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\smismatched\sprintf()\sargument\sand\sformat\sspecifier.\sAdd\sota\sfiles\sto\sMakefile.in.
-D 2015-04-16T14:33:09.849
+C Be\ssure\sto\srelease\sany\sxShmLock\slocks\sheld\swhen\sclosing\san\sOTA\shandle.
+D 2015-04-16T18:49:53.533
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 79b306896135a2305cfb7e6d88990fc4820fb917
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -134,11 +134,11 @@ F ext/ota/ota6.test 3bde7f69a894748b27206b6753462ec3b75b6bb6
 F ext/ota/ota7.test 1fe2c5761705374530e29f70c39693076028221a
 F ext/ota/ota8.test cd70e63a0c29c45c0906692827deafa34638feda
 F ext/ota/ota9.test d3eee95dd836824d07a22e5efcdb7bf6e869358b
-F ext/ota/otaA.test ef4bfa8cfd4ed814ae86f7457b64aa2f18c90171
+F ext/ota/otaA.test ab67f7f53670b81c750dcc946c5b704f51c429a4
 F ext/ota/otacrash.test a078d34e2edbcedac5f894e3e7d08d452a327007
 F ext/ota/otafault.test 8c43586c2b96ca16bbce00b5d7e7d67316126db8
 F ext/ota/otafault2.test fa202a98ca221faec318f3e5c5f39485b1256561
-F ext/ota/sqlite3ota.c 876445eb19a9d4b53a6c79e604748542d935f528
+F ext/ota/sqlite3ota.c 424d4b9a010a836003e3eab6d84d37774cb620ed
 F ext/ota/sqlite3ota.h f1a9dd98b00fa622c7e2eb68e580ee02e194c4d6
 F ext/ota/test_ota.c e34c801c665d64b4b9e00b71f1acf8c652404b2b
 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761
@@ -1269,7 +1269,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 658c3b0c80b9fe7eaac5982573651dc649a4c53f
-R 7c644ea03a0ef90234d338e031f21ca5
+P 5db810a88dac5cbf1f6b321345d01cc0d9d05d31
+R c5895a3241a2de3944e668930a0eb998
 U dan
-Z 85db6025ab0c4250cca566f7a293b04a
+Z dc29da0591555b6f4d89a9eb4ca47d9d
index 9d0960e97a63b5a0150937201e2f4c216ddd8f0e..596b727a52cba423dee5d6638d6edc22c61d5ad9 100644 (file)
@@ -1 +1 @@
-5db810a88dac5cbf1f6b321345d01cc0d9d05d31
\ No newline at end of file
+d0fba72a47f73082ade40a732aab114bc8f6d83e
\ No newline at end of file