mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-12 13:01:09 +03:00
Simplify the winRead and winWrite VFS functions to reduce the number
of system calls. FossilOrigin-Name: b34491869c4fb31d2fdd14c94a7db2e1c0e572ba
This commit is contained in:
12
manifest
12
manifest
@@ -1,5 +1,5 @@
|
|||||||
C When\sa\snamed\sCHECK\sconstraint\sfails,\sinclude\sthe\sname\sof\sthe\sconstraint\nin\sthe\serror\smessage.
|
C Simplify\sthe\swinRead\sand\swinWrite\sVFS\sfunctions\sto\sreduce\sthe\snumber\nof\ssystem\scalls.
|
||||||
D 2012-03-30T15:48:48.787
|
D 2012-03-30T15:57:45.451
|
||||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||||
F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20
|
F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20
|
||||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||||
@@ -168,7 +168,7 @@ F src/os.h 59beba555b65a450bd1d804220532971d4299f60
|
|||||||
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 0e3d2942d228d0366fb80a3640f35caf413b66d1
|
F src/os_unix.c 0e3d2942d228d0366fb80a3640f35caf413b66d1
|
||||||
F src/os_win.c 5ac061ae1326a71500cee578ed0fd9113b4f6a37
|
F src/os_win.c c7b26b78c5e62de7355ad79e0ce79d7b0f5fccc4
|
||||||
F src/pager.c 85988507fa20acc60defb834722eddf4633e4aeb
|
F src/pager.c 85988507fa20acc60defb834722eddf4633e4aeb
|
||||||
F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5
|
F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5
|
||||||
F src/parse.y eb054bb40a5bf90d3422a01ed0e5df229461727a
|
F src/parse.y eb054bb40a5bf90d3422a01ed0e5df229461727a
|
||||||
@@ -999,7 +999,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 cb7a850439c9a4a7887650d6b81d95ab8025de5b 9a0f90d9deb335ac71044b8afa81538d85cc7ccf
|
P 1b75f301affac654bee24fa247046ea0782d3c4d
|
||||||
R 3383713cde4154ba8c7927e87d965912
|
R 2cc6bffd476fbc89b05bef18789bd072
|
||||||
U drh
|
U drh
|
||||||
Z 044e1c348f17a4e06833c51581164485
|
Z 6ac97e4f60396b50617248087122bd36
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
1b75f301affac654bee24fa247046ea0782d3c4d
|
b34491869c4fb31d2fdd14c94a7db2e1c0e572ba
|
||||||
33
src/os_win.c
33
src/os_win.c
@@ -1616,6 +1616,9 @@ static int winClose(sqlite3_file *id){
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
OSTRACE(("CLOSE %d %s\n", pFile->h, rc ? "ok" : "failed"));
|
OSTRACE(("CLOSE %d %s\n", pFile->h, rc ? "ok" : "failed"));
|
||||||
|
if( rc ){
|
||||||
|
pFile->h = NULL;
|
||||||
|
}
|
||||||
OpenCounter(-1);
|
OpenCounter(-1);
|
||||||
return rc ? SQLITE_OK
|
return rc ? SQLITE_OK
|
||||||
: winLogError(SQLITE_IOERR_CLOSE, osGetLastError(),
|
: winLogError(SQLITE_IOERR_CLOSE, osGetLastError(),
|
||||||
@@ -1633,6 +1636,7 @@ static int winRead(
|
|||||||
int amt, /* Number of bytes to read */
|
int amt, /* Number of bytes to read */
|
||||||
sqlite3_int64 offset /* Begin reading at this offset */
|
sqlite3_int64 offset /* Begin reading at this offset */
|
||||||
){
|
){
|
||||||
|
OVERLAPPED overlapped; /* The offset for ReadFile. */
|
||||||
winFile *pFile = (winFile*)id; /* file handle */
|
winFile *pFile = (winFile*)id; /* file handle */
|
||||||
DWORD nRead; /* Number of bytes actually read from file */
|
DWORD nRead; /* Number of bytes actually read from file */
|
||||||
int nRetry = 0; /* Number of retrys */
|
int nRetry = 0; /* Number of retrys */
|
||||||
@@ -1641,10 +1645,11 @@ static int winRead(
|
|||||||
SimulateIOError(return SQLITE_IOERR_READ);
|
SimulateIOError(return SQLITE_IOERR_READ);
|
||||||
OSTRACE(("READ %d lock=%d\n", pFile->h, pFile->locktype));
|
OSTRACE(("READ %d lock=%d\n", pFile->h, pFile->locktype));
|
||||||
|
|
||||||
if( seekWinFile(pFile, offset) ){
|
memset(&overlapped, 0, sizeof(OVERLAPPED));
|
||||||
return SQLITE_FULL;
|
overlapped.Offset = (LONG)(offset & 0xffffffff);
|
||||||
}
|
overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);
|
||||||
while( !osReadFile(pFile->h, pBuf, amt, &nRead, 0) ){
|
while( !osReadFile(pFile->h, pBuf, amt, &nRead, &overlapped) &&
|
||||||
|
osGetLastError()!=ERROR_HANDLE_EOF ){
|
||||||
DWORD lastErrno;
|
DWORD lastErrno;
|
||||||
if( retryIoerr(&nRetry, &lastErrno) ) continue;
|
if( retryIoerr(&nRetry, &lastErrno) ) continue;
|
||||||
pFile->lastErrno = lastErrno;
|
pFile->lastErrno = lastErrno;
|
||||||
@@ -1671,7 +1676,7 @@ static int winWrite(
|
|||||||
int amt, /* Number of bytes to write */
|
int amt, /* Number of bytes to write */
|
||||||
sqlite3_int64 offset /* Offset into the file to begin writing at */
|
sqlite3_int64 offset /* Offset into the file to begin writing at */
|
||||||
){
|
){
|
||||||
int rc; /* True if error has occured, else false */
|
int rc = 0; /* True if error has occured, else false */
|
||||||
winFile *pFile = (winFile*)id; /* File handle */
|
winFile *pFile = (winFile*)id; /* File handle */
|
||||||
int nRetry = 0; /* Number of retries */
|
int nRetry = 0; /* Number of retries */
|
||||||
|
|
||||||
@@ -1682,19 +1687,29 @@ static int winWrite(
|
|||||||
|
|
||||||
OSTRACE(("WRITE %d lock=%d\n", pFile->h, pFile->locktype));
|
OSTRACE(("WRITE %d lock=%d\n", pFile->h, pFile->locktype));
|
||||||
|
|
||||||
rc = seekWinFile(pFile, offset);
|
{
|
||||||
if( rc==0 ){
|
OVERLAPPED overlapped; /* The offset for WriteFile. */
|
||||||
u8 *aRem = (u8 *)pBuf; /* Data yet to be written */
|
u8 *aRem = (u8 *)pBuf; /* Data yet to be written */
|
||||||
int nRem = amt; /* Number of bytes yet to be written */
|
int nRem = amt; /* Number of bytes yet to be written */
|
||||||
DWORD nWrite; /* Bytes written by each WriteFile() call */
|
DWORD nWrite; /* Bytes written by each WriteFile() call */
|
||||||
DWORD lastErrno = NO_ERROR; /* Value returned by GetLastError() */
|
DWORD lastErrno = NO_ERROR; /* Value returned by GetLastError() */
|
||||||
|
|
||||||
|
memset(&overlapped, 0, sizeof(OVERLAPPED));
|
||||||
|
overlapped.Offset = (LONG)(offset & 0xffffffff);
|
||||||
|
overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);
|
||||||
|
|
||||||
while( nRem>0 ){
|
while( nRem>0 ){
|
||||||
if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, 0) ){
|
if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, &overlapped) ){
|
||||||
if( retryIoerr(&nRetry, &lastErrno) ) continue;
|
if( retryIoerr(&nRetry, &lastErrno) ) continue;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if( nWrite<=0 ) break;
|
if( nWrite<=0 ){
|
||||||
|
lastErrno = osGetLastError();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
offset += nWrite;
|
||||||
|
overlapped.Offset = (LONG)(offset & 0xffffffff);
|
||||||
|
overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);
|
||||||
aRem += nWrite;
|
aRem += nWrite;
|
||||||
nRem -= nWrite;
|
nRem -= nWrite;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user