]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Change the xShmSize() implementation in os_unix.c so that it will only wal-refactor
authordrh <drh@noemail.net>
Thu, 13 May 2010 08:33:35 +0000 (08:33 +0000)
committerdrh <drh@noemail.net>
Thu, 13 May 2010 08:33:35 +0000 (08:33 +0000)
increase and never decrease the size of a shared-memory segment.

FossilOrigin-Name: 149d2ae4a6fe2f86822f286d2a7092c51bec7ebb

manifest
manifest.uuid
src/os_unix.c

index d8efdf0e53232840c0e375198c374c35935f5185..c850c8b0cea649f740821a5c765d74b04cc2b613 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,8 @@
-C Fix\sfor\sa\ssegfault\sthat\scan\sfollow\sa\smalloc\sfailure.
-D 2010-05-13T07:08:54
+-----BEGIN PGP SIGNED MESSAGE-----
+Hash: SHA1
+
+C Change\sthe\sxShmSize()\simplementation\sin\sos_unix.c\sso\sthat\sit\swill\sonly\nincrease\sand\snever\sdecrease\sthe\ssize\sof\sa\sshared-memory\ssegment.
+D 2010-05-13T08:33:36
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in a5cad1f8f3e021356bfcc6c77dc16f6f1952bbc3
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -152,7 +155,7 @@ F src/os.c c0a5dfce2a214dacb679425632d04f8a2021f364
 F src/os.h 8a7e2456237ecf3a2e55b02f9fe6091f1ad36902
 F src/os_common.h 0d6ee583b6ee3185eb9d951f890c6dd03021a08d
 F src/os_os2.c 8ad77a418630d7dee91d1bb04f79c2096301d3a0
-F src/os_unix.c c7ff5a947fc0a09de1c9c2008e3646551a1a8137
+F src/os_unix.c a65eb0c527306fbf8d5818c068cccb4179e2c187
 F src/os_win.c a8fc01d8483be472e495793c01064fd87e56a5c1
 F src/pager.c 1e163a82ae8405433dca559831caa06aafbba3b0
 F src/pager.h 76466c3a5af56943537f68b1f16567101a0cd1d0
@@ -814,7 +817,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P 25e72f81561575051c63e9bf5d2c8e76f9fcf5c6
-R d6f93e9926f16286e5aafb3fc350bd84
-U dan
-Z c60bce3aa77615040a5ca2d947852fe0
+P 3cab9022457ce50f82c5822d8ba6c04a3a85cb6a
+R 8a7d44076bf0e05c11800be3998eddd6
+U drh
+Z 3a36caf9fe5b6632b303e603e184218b
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.6 (GNU/Linux)
+
+iD8DBQFL67ljoxKgR168RlERAvKRAJ9jAZ2qvV6Q9GpsBE6wLhS3nq7pbACfcnYP
+hXJABDPCTP9dztwWLTfVSAc=
+=rTx0
+-----END PGP SIGNATURE-----
index 7b1e6c33dfe651f85d21d70f0f4d817d389b55a8..46bd746c8ff1e2e4724caf8529c0a8e2bc748f96 100644 (file)
@@ -1 +1 @@
-3cab9022457ce50f82c5822d8ba6c04a3a85cb6a
\ No newline at end of file
+149d2ae4a6fe2f86822f286d2a7092c51bec7ebb
\ No newline at end of file
index ff967ca8b96aa0b14fc1a971e9a1e89020200ff1..4ddff190ae3528c0f42f1a2e76896efc2e4c323d 100644 (file)
@@ -3957,16 +3957,25 @@ static int unixShmSize(
   int rc = SQLITE_OK;
   struct stat sStat;
 
-  if( reqSize>=0 ){
+  /* On a query, this loop runs once.  When reqSize>=0, the loop potentially
+  ** runs twice, except if the actual size is already greater than or equal
+  ** to the requested size, reqSize is set to -1 on the first iteration and
+  ** the loop only runs once.
+  */
+  while( 1 ){
+    if( fstat(pFile->h, &sStat)==0 ){
+      *pNewSize = (int)sStat.st_size;
+      if( reqSize>=0 && reqSize<=(int)sStat.st_size ) break;
+    }else{
+      *pNewSize = 0;
+      rc = SQLITE_IOERR;
+      break;
+    }
+    if( reqSize<0 ) break;
     reqSize = (reqSize + SQLITE_UNIX_SHM_INCR - 1)/SQLITE_UNIX_SHM_INCR;
     reqSize *= SQLITE_UNIX_SHM_INCR;
     rc = ftruncate(pFile->h, reqSize);
-  }
-  if( fstat(pFile->h, &sStat)==0 ){
-    *pNewSize = (int)sStat.st_size;
-  }else{
-    *pNewSize = 0;
-    rc = SQLITE_IOERR;
+    reqSize = -1;
   }
   return rc;
 }