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

Make the unix VFS tolerant of read() calls that return less than the

requested number of bytes.

FossilOrigin-Name: a210695abcfa5cb04279edfd04824d881b7c4ada
This commit is contained in:
drh
2011-11-07 18:16:00 +00:00
parent a46739eae0
commit 5802464316
3 changed files with 39 additions and 26 deletions

View File

@@ -1,5 +1,5 @@
C Amplify\sthe\srestriction\son\scommit-hooks\sthat\sthey\scannot\srecursively\nrun\sSQL\son\sthe\ssame\sdatabase\sconnection. C Make\sthe\sunix\sVFS\stolerant\sof\sread()\scalls\sthat\sreturn\sless\sthan\sthe\nrequested\snumber\sof\sbytes.
D 2011-11-07T17:54:26.821 D 2011-11-07T18:16:00.449
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 5b4a3e12a850b021547e43daf886b25133b44c07 F Makefile.in 5b4a3e12a850b021547e43daf886b25133b44c07
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -166,7 +166,7 @@ F src/os.c 5d9b02782ed36345348d6fe21d7762ed3a9cfd2a
F src/os.h 9dbed8c2b9c1f2f2ebabc09e49829d4777c26bf9 F src/os.h 9dbed8c2b9c1f2f2ebabc09e49829d4777c26bf9
F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 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/os_win.c 49d418916428a59d773f39993db0ecde56ab4c37
F src/pager.c db33d4bf1e3e019c34c220971cc6c3aa07c30f54 F src/pager.c db33d4bf1e3e019c34c220971cc6c3aa07c30f54
F src/pager.h 9f81b08efb06db4ba8be69446e10b005c351373d F src/pager.h 9f81b08efb06db4ba8be69446e10b005c351373d
@@ -974,7 +974,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
P f521b6b7e42c82f09a91df5a5acf4e46c860e72a P 4fe5b73115a8b44950767f1b528107261d7312c9
R 55cca41ab47514d8db108b3f26e18c32 R 235506ff1af96e54491bff797f85e25a
U drh U drh
Z a1378b40deb34e0ef30ad969852d18f3 Z b43cdd5d2255740ef7ed4b6994dd0923

View File

@@ -1 +1 @@
4fe5b73115a8b44950767f1b528107261d7312c9 a210695abcfa5cb04279edfd04824d881b7c4ada

View 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){ static int seekAndRead(unixFile *id, sqlite3_int64 offset, void *pBuf, int cnt){
int got; int got;
int prior = 0;
#if (!defined(USE_PREAD) && !defined(USE_PREAD64)) #if (!defined(USE_PREAD) && !defined(USE_PREAD64))
i64 newOffset; i64 newOffset;
#endif #endif
TIMER_START; TIMER_START;
do{
#if defined(USE_PREAD) #if defined(USE_PREAD)
do{ got = osPread(id->h, pBuf, cnt, offset); }while( got<0 && errno==EINTR ); got = osPread(id->h, pBuf, cnt, offset);
SimulateIOError( got = -1 ); SimulateIOError( got = -1 );
#elif defined(USE_PREAD64) #elif defined(USE_PREAD64)
do{ got = osPread64(id->h, pBuf, cnt, offset); }while( got<0 && errno==EINTR); got = osPread64(id->h, pBuf, cnt, offset);
SimulateIOError( got = -1 ); SimulateIOError( got = -1 );
#else #else
newOffset = lseek(id->h, offset, SEEK_SET); newOffset = lseek(id->h, offset, SEEK_SET);
SimulateIOError( newOffset-- ); SimulateIOError( newOffset-- );
if( newOffset!=offset ){ if( newOffset!=offset ){
if( newOffset == -1 ){ if( newOffset == -1 ){
((unixFile*)id)->lastErrno = errno; ((unixFile*)id)->lastErrno = errno;
}else{ }else{
((unixFile*)id)->lastErrno = 0; ((unixFile*)id)->lastErrno = 0;
}
return -1;
} }
return -1; got = osRead(id->h, pBuf, cnt);
}
do{ got = osRead(id->h, pBuf, cnt); }while( got<0 && errno==EINTR );
#endif #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; TIMER_END;
if( got<0 ){ OSTRACE(("READ %-3d %5d %7lld %llu\n",
((unixFile*)id)->lastErrno = errno; id->h, got+prior, offset-prior, TIMER_ELAPSED));
} return got+prior;
OSTRACE(("READ %-3d %5d %7lld %llu\n", id->h, got, offset, TIMER_ELAPSED));
return got;
} }
/* /*