]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add extra #ifndef statements in os_unix.c and os_win.c to make sure the
authordrh <drh@noemail.net>
Tue, 9 Apr 2013 16:19:20 +0000 (16:19 +0000)
committerdrh <drh@noemail.net>
Tue, 9 Apr 2013 16:19:20 +0000 (16:19 +0000)
memory mapped I/O really is disabled when SQLITE_DISABLE_MMAP is set.

FossilOrigin-Name: c1e2523c9051782569291fff998140f7e0b70b6d

manifest
manifest.uuid
src/os_unix.c
src/os_win.c

index fdbb616c1daee7ca9d6382da75e740f7e67b7394..7f8d4dc923a4a6d8129dda7d285d86bd78a6d21f 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Disable\sthe\suse\sof\smemory-mapped\sI/O\sif\sthe\sSQLITE_DISABLE_MMAP\smacro\sis\ndefined.\s\sAutomatically\sdefine\sthis\smacro\sfor\sOpenBSD\sand\sQNX.\s\sOther\nsystems\sare\slikely\sto\sbe\sadded\sto\sthe\sdisabled\slist\sover\stime.
-D 2013-04-08T20:47:49.018
+C Add\sextra\s#ifndef\sstatements\sin\sos_unix.c\sand\sos_win.c\sto\smake\ssure\sthe\nmemory\smapped\sI/O\sreally\sis\sdisabled\swhen\sSQLITE_DISABLE_MMAP\sis\sset.
+D 2013-04-09T16:19:20.624
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 6a6a8c548822302d3a9a651f0296bbc3dad55e83
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -166,8 +166,8 @@ F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30
 F src/os.c ca679b293a6233327e418fd1dde2cd5db3e90932
 F src/os.h ae08bcc5f6ec6b339f4a2adf3931bb88cc14c3e4
 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
-F src/os_unix.c 6d584190db2ed442e5c849b7f73dcfbbac7c032e
-F src/os_win.c 3265df8c762e0b8caf8d02b3352fa8c22e91ae6b
+F src/os_unix.c a6e9caadd8956a39153d1bd920e459211a281388
+F src/os_win.c 3aec291c40048653c00a153fee96d3a442ab85ee
 F src/pager.c eb6d272f4dc1ade4b8f664599cd54a9c95cb2729
 F src/pager.h 5cb78b8e1adfd5451e600be7719f5a99d87ac3b1
 F src/parse.y 5d5e12772845805fdfeb889163516b84fbb9ae95
@@ -1050,7 +1050,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
-P ae8bb24bfb014bdcb8aaa8159ddae0cd376afe99
-R 7e782b1e3841573f5a2d86903a4acfcf
+P 8a4314a398c6c6efb25e6993c826b7e60d9bb1f9
+R 815c6131bff16243fe333d79ef346ae3
 U drh
-Z a7d6d975495e51a139482ed48c14db14
+Z 73d68bfce668b2e7f104132473fd4e42
index 387ecfb3dc0dcdb403562d159b8111f97b95a81e..991d418bcd9becdf283a72555b6fc6aed7cfc2fe 100644 (file)
@@ -1 +1 @@
-8a4314a398c6c6efb25e6993c826b7e60d9bb1f9
\ No newline at end of file
+c1e2523c9051782569291fff998140f7e0b70b6d
\ No newline at end of file
index 1d4c8ad3487b161f5be130d153d19564bedcfede..a65f894eb8c654395eb83ce26a707dd487a68601 100644 (file)
@@ -3117,6 +3117,7 @@ static int unixRead(
   );
 #endif
 
+#if !defined(SQLITE_DISABLE_MMAP)
   /* Deal with as much of this read request as possible by transfering
   ** data from the memory mapping using memcpy().  */
   if( offset<pFile->mmapSize ){
@@ -3131,6 +3132,7 @@ static int unixRead(
       offset += nCopy;
     }
   }
+#endif
 
   got = seekAndRead(pFile, offset, pBuf, amt);
   if( got==amt ){
@@ -3236,6 +3238,7 @@ static int unixWrite(
   }
 #endif
 
+#if !defined(SQLITE_DISABLE_MMAP)
   /* Deal with as much of this write request as possible by transfering
   ** data from the memory mapping using memcpy().  */
   if( offset<pFile->mmapSize ){
@@ -3250,6 +3253,7 @@ static int unixWrite(
       offset += nCopy;
     }
   }
+#endif
 
   while( amt>0 && (wrote = seekAndWrite(pFile, offset, pBuf, amt))>0 ){
     amt -= wrote;
@@ -4525,12 +4529,14 @@ static int unixShmUnmap(
 */
 static void unixUnmapfile(unixFile *pFd){
   assert( pFd->nFetchOut==0 );
+#ifndef SQLITE_DISABLE_MMAP
   if( pFd->pMapRegion ){
     osMunmap(pFd->pMapRegion, pFd->mmapOrigsize);
     pFd->pMapRegion = 0;
     pFd->mmapSize = 0;
     pFd->mmapOrigsize = 0;
   }
+#endif
 }
 
 /*
@@ -4546,6 +4552,7 @@ static int unixGetPagesize(void){
 #endif
 }
 
+#ifndef SQLITE_DISABLE_MMAP
 /*
 ** Attempt to set the size of the memory mapping maintained by file 
 ** descriptor pFd to nNew bytes. Any existing mapping is discarded.
@@ -4630,6 +4637,7 @@ static void unixRemapfile(
   pFd->pMapRegion = (void *)pNew;
   pFd->mmapSize = pFd->mmapOrigsize = nNew;
 }
+#endif
 
 /*
 ** Memory map or remap the file opened by file-descriptor pFd (if the file
@@ -4651,6 +4659,7 @@ static int unixMapfile(unixFile *pFd, i64 nByte){
   i64 nMap = nByte;
   int rc;
 
+#ifndef SQLITE_DISABLE_MMAP
   assert( nMap>=0 || pFd->nFetchOut==0 );
   if( pFd->nFetchOut>0 ) return SQLITE_OK;
 
@@ -4673,6 +4682,7 @@ static int unixMapfile(unixFile *pFd, i64 nByte){
       unixUnmapfile(pFd);
     }
   }
+#endif
 
   return SQLITE_OK;
 }
@@ -4693,6 +4703,7 @@ static int unixFetch(sqlite3_file *fd, i64 iOff, int nAmt, void **pp){
   unixFile *pFd = (unixFile *)fd;   /* The underlying database file */
   *pp = 0;
 
+#ifndef SQLITE_DISABLE_MMAP
   if( pFd->mmapLimit>0 ){
     if( pFd->pMapRegion==0 ){
       int rc = unixMapfile(pFd, -1);
@@ -4703,6 +4714,7 @@ static int unixFetch(sqlite3_file *fd, i64 iOff, int nAmt, void **pp){
       pFd->nFetchOut++;
     }
   }
+#endif
   return SQLITE_OK;
 }
 
index a7966171b5e2e720085fba3c144b795270d78628..220ebac268f2378c175aea0edb38d3635aa489c7 100644 (file)
@@ -2148,6 +2148,7 @@ static int winRead(
   SimulateIOError(return SQLITE_IOERR_READ);
   OSTRACE(("READ %d lock=%d\n", pFile->h, pFile->locktype));
 
+#if !defined(SQLITE_DISABLE_MMAP)
   /* Deal with as much of this read request as possible by transfering
   ** data from the memory mapping using memcpy().  */
   if( offset<pFile->mmapSize ){
@@ -2162,6 +2163,7 @@ static int winRead(
       offset += nCopy;
     }
   }
+#endif
 
 #if SQLITE_OS_WINCE
   if( seekWinFile(pFile, offset) ){
@@ -2212,6 +2214,7 @@ static int winWrite(
 
   OSTRACE(("WRITE %d lock=%d\n", pFile->h, pFile->locktype));
 
+#if !defined(SQLITE_DISABLE_MMAP)
   /* Deal with as much of this write request as possible by transfering
   ** data from the memory mapping using memcpy().  */
   if( offset<pFile->mmapSize ){
@@ -2226,6 +2229,7 @@ static int winWrite(
       offset += nCopy;
     }
   }
+#endif
 
 #if SQLITE_OS_WINCE
   rc = seekWinFile(pFile, offset);
@@ -2321,6 +2325,7 @@ static int winTruncate(sqlite3_file *id, sqlite3_int64 nByte){
                      "winTruncate2", pFile->zPath);
   }
 
+#if !defined(SQLITE_DISABLE_MMAP)
   /* If the file was truncated to a size smaller than the currently
   ** mapped region, reduce the effective mapping size as well. SQLite will
   ** use read() and write() to access data beyond this point from now on.
@@ -2328,6 +2333,7 @@ static int winTruncate(sqlite3_file *id, sqlite3_int64 nByte){
   if( pFile->pMapRegion && nByte<pFile->mmapSize ){
     pFile->mmapSize = nByte;
   }
+#endif
 
   OSTRACE(("TRUNCATE %d %lld %s\n", pFile->h, nByte, rc ? "failed" : "ok"));
   return rc;
@@ -3517,6 +3523,7 @@ shmpage_out:
 */
 static int winUnmapfile(winFile *pFile){
   assert( pFile!=0 );
+#if !defined(SQLITE_DISABLE_MMAP)
   if( pFile->pMapRegion ){
     if( !osUnmapViewOfFile(pFile->pMapRegion) ){
       pFile->lastErrno = osGetLastError();
@@ -3535,9 +3542,11 @@ static int winUnmapfile(winFile *pFile){
     }
     pFile->hMap = NULL;
   }
+#endif
   return SQLITE_OK;
 }
 
+#if !defined(SQLITE_DISABLE_MMAP)
 /*
 ** Memory map or remap the file opened by file-descriptor pFd (if the file
 ** is already mapped, the existing mapping is replaced by the new). Or, if 
@@ -3625,6 +3634,7 @@ static int winMapfile(winFile *pFd, sqlite3_int64 nByte){
 
   return SQLITE_OK;
 }
+#endif /* !defined(SQLITE_DISABLE_MMAP) */
 
 /*
 ** If possible, return a pointer to a mapping of file fd starting at offset
@@ -3642,6 +3652,7 @@ static int winFetch(sqlite3_file *fd, i64 iOff, int nAmt, void **pp){
   winFile *pFd = (winFile*)fd;   /* The underlying database file */
   *pp = 0;
 
+#if !defined(SQLITE_DISABLE_MMAP)
   if( pFd->mmapLimit>0 ){
     if( pFd->pMapRegion==0 ){
       int rc = winMapfile(pFd, -1);
@@ -3652,6 +3663,7 @@ static int winFetch(sqlite3_file *fd, i64 iOff, int nAmt, void **pp){
       pFd->nFetchOut++;
     }
   }
+#endif
   return SQLITE_OK;
 }