]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Make the unix VFS tolerant of read() calls that return less than the
authordrh <drh@noemail.net>
Mon, 7 Nov 2011 18:16:00 +0000 (18:16 +0000)
committerdrh <drh@noemail.net>
Mon, 7 Nov 2011 18:16:00 +0000 (18:16 +0000)
requested number of bytes.

FossilOrigin-Name: a210695abcfa5cb04279edfd04824d881b7c4ada

manifest
manifest.uuid
src/os_unix.c

index fddf3bd4842fe2506d0b905805ad3eca787f2b65..4ac21d9d508dd4ad017c70d207dab7b6e0cad26b 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Amplify\sthe\srestriction\son\scommit-hooks\sthat\sthey\scannot\srecursively\nrun\sSQL\son\sthe\ssame\sdatabase\sconnection.
-D 2011-11-07T17:54:26.821
+C Make\sthe\sunix\sVFS\stolerant\sof\sread()\scalls\sthat\sreturn\sless\sthan\sthe\nrequested\snumber\sof\sbytes.
+D 2011-11-07T18:16:00.449
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 5b4a3e12a850b021547e43daf886b25133b44c07
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -166,7 +166,7 @@ F src/os.c 5d9b02782ed36345348d6fe21d7762ed3a9cfd2a
 F src/os.h 9dbed8c2b9c1f2f2ebabc09e49829d4777c26bf9
 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440
-F src/os_unix.c 32f2ac2adbbba6acb649915a6953524ecf4cf9d5
+F src/os_unix.c 4fbb91726165e105c1679a2660f49a3f4c376e4f
 F src/os_win.c 49d418916428a59d773f39993db0ecde56ab4c37
 F src/pager.c db33d4bf1e3e019c34c220971cc6c3aa07c30f54
 F src/pager.h 9f81b08efb06db4ba8be69446e10b005c351373d
@@ -974,7 +974,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
 F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a
 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
-P f521b6b7e42c82f09a91df5a5acf4e46c860e72a
-R 55cca41ab47514d8db108b3f26e18c32
+P 4fe5b73115a8b44950767f1b528107261d7312c9
+R 235506ff1af96e54491bff797f85e25a
 U drh
-Z a1378b40deb34e0ef30ad969852d18f3
+Z b43cdd5d2255740ef7ed4b6994dd0923
index 46bd34afcc933ae66adbb668e5139810800c5802..26a58694303178edfc4510fc692470f887d37a5f 100644 (file)
@@ -1 +1 @@
-4fe5b73115a8b44950767f1b528107261d7312c9
\ No newline at end of file
+a210695abcfa5cb04279edfd04824d881b7c4ada
\ No newline at end of file
index 5ca3415a5300350101cc820955ac30cee1cd8e88..51d144906a69661bed8287ab8416f9c40da46eef 100644 (file)
@@ -2951,35 +2951,48 @@ static int nfsUnlock(sqlite3_file *id, int eFileLock){
 */
 static int seekAndRead(unixFile *id, sqlite3_int64 offset, void *pBuf, int cnt){
   int got;
+  int prior = 0;
 #if (!defined(USE_PREAD) && !defined(USE_PREAD64))
   i64 newOffset;
 #endif
   TIMER_START;
+  do{
 #if defined(USE_PREAD)
-  do{ got = osPread(id->h, pBuf, cnt, offset); }while( got<0 && errno==EINTR );
-  SimulateIOError( got = -1 );
+    got = osPread(id->h, pBuf, cnt, offset);
+    SimulateIOError( got = -1 );
 #elif defined(USE_PREAD64)
-  do{ got = osPread64(id->h, pBuf, cnt, offset); }while( got<0 && errno==EINTR);
-  SimulateIOError( got = -1 );
+    got = osPread64(id->h, pBuf, cnt, offset);
+    SimulateIOError( got = -1 );
 #else
-  newOffset = lseek(id->h, offset, SEEK_SET);
-  SimulateIOError( newOffset-- );
-  if( newOffset!=offset ){
-    if( newOffset == -1 ){
-      ((unixFile*)id)->lastErrno = errno;
-    }else{
-      ((unixFile*)id)->lastErrno = 0;                  
+    newOffset = lseek(id->h, offset, SEEK_SET);
+    SimulateIOError( newOffset-- );
+    if( newOffset!=offset ){
+      if( newOffset == -1 ){
+        ((unixFile*)id)->lastErrno = errno;
+      }else{
+        ((unixFile*)id)->lastErrno = 0;                        
+      }
+      return -1;
     }
-    return -1;
-  }
-  do{ got = osRead(id->h, pBuf, cnt); }while( got<0 && errno==EINTR );
+    got = osRead(id->h, pBuf, cnt);
 #endif
+    if( got==cnt ) break;
+    if( got<0 ){
+      if( errno==EINTR ){ got = 1; continue; }
+      prior = 0;
+      ((unixFile*)id)->lastErrno = errno;
+      break;
+    }else if( got>0 ){
+      cnt -= got;
+      offset += got;
+      prior += got;
+      pBuf = (void*)(got + (char*)pBuf);
+    }
+  }while( got>0 );
   TIMER_END;
-  if( got<0 ){
-    ((unixFile*)id)->lastErrno = errno;
-  }
-  OSTRACE(("READ    %-3d %5d %7lld %llu\n", id->h, got, offset, TIMER_ELAPSED));
-  return got;
+  OSTRACE(("READ    %-3d %5d %7lld %llu\n",
+            id->h, got+prior, offset-prior, TIMER_ELAPSED));
+  return got+prior;
 }
 
 /*