]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
When available, use posix_fallocate() rather than ftruncate() to allocate
authordrh <drh@noemail.net>
Tue, 13 Nov 2012 10:54:12 +0000 (10:54 +0000)
committerdrh <drh@noemail.net>
Tue, 13 Nov 2012 10:54:12 +0000 (10:54 +0000)
space for mmap()ed -shm files, since posix_fallocate() gives an error if
no disk space is available whereas ftruncate() is silent and leaves the system
vulnerable to a SIGBUS upon first write to the mmap()ed region.
Ticket [5eaa61ea1881040b17449ca043b6f8fd9ca55dc3]

FossilOrigin-Name: 356259617cfad04492a02912fdf781f54a2b4494

manifest
manifest.uuid
src/os_unix.c
test/wal9.test

index 028b6852d1b9d9207e60a61002e3942aca47f492..ef2f6d3b5910386bd4fd3b982c0b6a6dd9eb4c45 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Only\slog\sunlink()\serrors\sif\sthe\serror\sis\ssomething\sother\sthan\nSQLITE_IOERR_DELETE_NOENT.\s\sThe\serror\sis\sstill\sreported\sup\sthe\sstack,\sit\nis\ssimply\snot\sadded\sto\sthe\ssqlite3_log().
-D 2012-11-09T21:40:02.069
+C When\savailable,\suse\sposix_fallocate()\srather\sthan\sftruncate()\sto\sallocate\nspace\sfor\smmap()ed\s-shm\sfiles,\ssince\sposix_fallocate()\sgives\san\serror\sif\nno\sdisk\sspace\sis\savailable\swhereas\sftruncate()\sis\ssilent\sand\sleaves\sthe\ssystem\nvulnerable\sto\sa\sSIGBUS\supon\sfirst\swrite\sto\sthe\smmap()ed\sregion.\nTicket\s[5eaa61ea1881040b17449ca043b6f8fd9ca55dc3]
+D 2012-11-13T10:54:12.768
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 82c41c0ed4cc94dd3cc7d498575b84c57c2c2384
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -160,7 +160,7 @@ F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30
 F src/os.c e1acdc09ff3ac2412945cca9766e2dcf4675f31c
 F src/os.h 027491c77d2404c0a678bb3fb06286f331eb9b57
 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
-F src/os_unix.c f0753566e1125d8b2eef6dd080b48ed91a83d424
+F src/os_unix.c fad4c9cbf89aa5e5de1f5972458c39bd75418b16
 F src/os_win.c 43ec1285357e5d5d919cb0492eac775c58ad7d12
 F src/pager.c ed53fe75a269c1d67645fe079ea0f3f0ce6492d5
 F src/pager.h 1109a06578ec5574dc2c74cf8d9f69daf36fe3e0
@@ -943,7 +943,7 @@ F test/wal5.test f58ed4b8b542f71c7441da12fbd769d99b362437
 F test/wal6.test 2e3bc767d9c2ce35c47106148d43fcbd072a93b3
 F test/wal7.test 2ae8f427d240099cc4b2dfef63cff44e2a68a1bd
 F test/wal8.test b3ee739fe8f7586aaebdc2367f477ebcf3e3b034
-F test/wal9.test b4eb5d27170c65ee9c8ff9c9e76babd902a13cfc
+F test/wal9.test 48c40803faf6849515c81213697e9f3376835981
 F test/wal_common.tcl a98f17fba96206122eff624db0ab13ec377be4fe
 F test/walbak.test b9f68e39646375c2b877be906babcc15d38b4877
 F test/walbig.test f437473a16cfb314867c6b5d1dbcd519e73e3434
@@ -1024,7 +1024,10 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
-P bed9c172ce624ab7b5b9de9ad42444891717ad9a
-R 6c7c8f8d3a3d00e4614865ddb6f518c4
+P 5a3b07f0f5dfae7eea870303f52f37d6a17f1da2
+R 457e538f0280386531160ea4b104ea9e
+T *branch * tkt-5eaa61ea18
+T *sym-tkt-5eaa61ea18 *
+T -sym-trunk *
 U drh
-Z 81d94dfa08446549954e693bf8235ef9
+Z 97e3b0ff73b00a5f41754576708d0771
index eae5c05106637886940585d3736beea127af7584..4ca6494d310f1fa7c0699834433e0cc97dc0b084 100644 (file)
@@ -1 +1 @@
-5a3b07f0f5dfae7eea870303f52f37d6a17f1da2
\ No newline at end of file
+356259617cfad04492a02912fdf781f54a2b4494
\ No newline at end of file
index ca62139430651b2f0cff02a8d9449b5d31031521..21ec0fda9e5a118b6d15b7a8c290d365f096e234 100644 (file)
@@ -4168,11 +4168,19 @@ static int unixShmMap(
         ** the requested memory region.
         */
         if( !bExtend ) goto shmpage_out;
+#if defined(HAVE_POSIX_FALLOCATE) && HAVE_POSIX_FALLOCATE
+        if( osFallocate(pShmNode->h, sStat.st_size, nByte)!=0 ){
+          rc = unixLogError(SQLITE_IOERR_SHMSIZE, "fallocate",
+                            pShmNode->zFilename);
+          goto shmpage_out;
+        }
+#else
         if( robust_ftruncate(pShmNode->h, nByte) ){
           rc = unixLogError(SQLITE_IOERR_SHMSIZE, "ftruncate",
                             pShmNode->zFilename);
           goto shmpage_out;
         }
+#endif
       }
     }
 
index a219e308844551dbe409a531525881da2a4c940e..f483eb615cdedf3feddaed5b5aad9ffdccad7573 100644 (file)
@@ -62,7 +62,7 @@ do_execsql_test 1.2 {
 # the *shm file is now more than one chunk (>32KiB).
 do_test 1.3 { file size test.db     } {1024}
 do_test 1.4 { file size test.db-wal } {15421352}
-do_test 1.5 { file size test.db-shm } {131072}
+do_test 1.5 { expr {[file size test.db-shm]>32768} } {1}
 
 do_execsql_test 1.6 { PRAGMA wal_checkpoint } {0 14715 14715}
 
@@ -87,4 +87,3 @@ do_test 1.7 {
 db2 close
 
 finish_test
-