diff options
author | git-lg-database.lge.com <lg-database@lge.com> | 2012-12-10 09:00:31 +0900 |
---|---|---|
committer | git-lg-database.lge.com <lg-database@lge.com> | 2012-12-10 09:00:31 +0900 |
commit | 1eb051da2d460037a748d574b128cdd33b6d8b28 (patch) | |
tree | 2ee3f8de3983a03b799fa23c3d2e8c9ac2b504fa | |
parent | 42c3f41862cfff8d4539903e47a42cae97d13d37 (diff) | |
download | android_external_sqlite-1eb051da2d460037a748d574b128cdd33b6d8b28.tar.gz android_external_sqlite-1eb051da2d460037a748d574b128cdd33b6d8b28.tar.bz2 android_external_sqlite-1eb051da2d460037a748d574b128cdd33b6d8b28.zip |
Fix bugs of sqlite that returns SIGBUS on disk full in WAL mode
Attempts to prepare a query on a WAL database when the disk space is
critically low result in the process killed with SIGBUS.
The crash happens in walIndexWriteHdr invoked from walIndexRecover.
Some Providers that using WAL mode like as SettingsProvider and MediaProvider
get failed in case of disk full with SIGBUS.
This patch changes unixShmMap() to call fallocate() instead of ftruncate.
In case of disk full, fallocate() will return SQLITE_FULL.
This patch is originated from www.sqlite.org.
(URL: http://www.sqlite.org/src/info/5eaa61ea18)
To simplify error status, returned error code is changed
from SQLITE_IOERR_SHMSIZE to SQLITE_FULL.
[written by Yongil Jang <yi.jang@lge.com>]
Change-Id: Idf3cbdab1ed4a4f2bc1b2b93ab6d8900edc7ee05
-rw-r--r-- | dist/sqlite3.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/dist/sqlite3.c b/dist/sqlite3.c index abe6186..9d01a51 100644 --- a/dist/sqlite3.c +++ b/dist/sqlite3.c @@ -24853,6 +24853,13 @@ SQLITE_API int sqlite3_os_end(void){ */ #if SQLITE_OS_UNIX /* This file is used on unix only */ +/* Use posix_fallocate() if it is available +*/ +#if !defined(HAVE_POSIX_FALLOCATE) \ + && (_XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L) +# define HAVE_POSIX_FALLOCATE 1 +#endif + /* ** There are various methods for file locking used for concurrency ** control: @@ -29091,11 +29098,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_FULL, "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 } } |