diff options
author | dan <dan@noemail.net> | 2014-12-30 14:40:53 +0000 |
---|---|---|
committer | dan <dan@noemail.net> | 2014-12-30 14:40:53 +0000 |
commit | d348c66e2971fe9de3ec832e54c24348bfcec8ec (patch) | |
tree | aacb0e0485c672089ee6a32b8a28f6c27b97656d /src/os_unix.c | |
parent | 51dc84eb7053963a6236e0a10dd3936bf4bd1378 (diff) | |
download | sqlite-d348c66e2971fe9de3ec832e54c24348bfcec8ec.tar.gz sqlite-d348c66e2971fe9de3ec832e54c24348bfcec8ec.zip |
If the sorter uses mmap'd temp files, ensure all pages of the temp file have been allocated before it is accessed. Otherwise, a disk-full condition might result in a SIGBUS exception.
FossilOrigin-Name: 776648412c30dce206f1024ff849c2cb025bb006
Diffstat (limited to 'src/os_unix.c')
-rw-r--r-- | src/os_unix.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index a9344ee83..8314e4f67 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -3718,16 +3718,16 @@ static int fcntlSizeHint(unixFile *pFile, i64 nByte){ int nBlk = buf.st_blksize; /* File-system block size */ i64 iWrite; /* Next offset to write to */ - if( robust_ftruncate(pFile->h, nSize) ){ - pFile->lastErrno = errno; - return unixLogError(SQLITE_IOERR_TRUNCATE, "ftruncate", pFile->zPath); - } iWrite = ((buf.st_size + 2*nBlk - 1)/nBlk)*nBlk-1; while( iWrite<nSize ){ int nWrite = seekAndWrite(pFile, iWrite, "", 1); if( nWrite!=1 ) return SQLITE_IOERR_WRITE; iWrite += nBlk; } + if( robust_ftruncate(pFile->h, nSize) ){ + pFile->lastErrno = errno; + return unixLogError(SQLITE_IOERR_TRUNCATE, "ftruncate", pFile->zPath); + } #endif } } |