1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-12 13:01:09 +03:00

When using mmap mode on unix, use a read-only mapping by default. Write to the database file using write(). Unless SQLITE_MMAP_READWRITE is defined, in which case use a read/write mapping and write into the file using memcpy().

FossilOrigin-Name: 67c5d3c646c8198c8637069140aca952b802df25
This commit is contained in:
dan
2015-11-17 20:56:06 +00:00
parent bfe8bd5a5e
commit fe33e39ba6
3 changed files with 11 additions and 9 deletions

View File

@@ -3349,7 +3349,7 @@ static int unixWrite(
}
#endif
#if SQLITE_MAX_MMAP_SIZE>0
#if defined(SQLITE_MMAP_READWRITE) && SQLITE_MAX_MMAP_SIZE>0
/* Deal with as much of this write request as possible by transfering
** data from the memory mapping using memcpy(). */
if( offset<pFile->mmapSize ){
@@ -4774,7 +4774,9 @@ static void unixRemapfile(
assert( pFd->mmapSizeActual>=pFd->mmapSize );
assert( MAP_FAILED!=0 );
#ifdef SQLITE_MMAP_READWRITE
if( (pFd->ctrlFlags & UNIXFILE_RDONLY)==0 ) flags |= PROT_WRITE;
#endif
if( pOrig ){
#if HAVE_MREMAP