From 8e86b6a3df4749565a173c9dff48d6d516b09af9 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Wed, 28 May 2014 03:27:42 +0000 Subject: [PATCH] Revise locking retry semantics in Win32 VFS to abort early if the file handle is reported as invalid. FossilOrigin-Name: d43e2e59b5647655595fd953febf2beefa480006 --- manifest | 15 +++++++++------ manifest.uuid | 2 +- src/os_win.c | 8 ++++++++ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index faef47fa27..618ec27c47 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Revise\show\sOSTRACE\sreports\slogically\sboolean\sresults\sin\sthe\sWin32\sVFS. -D 2014-05-28T03:23:55.937 +C Revise\slocking\sretry\ssemantics\sin\sWin32\sVFS\sto\sabort\searly\sif\sthe\sfile\shandle\sis\sreported\sas\sinvalid. +D 2014-05-28T03:27:42.937 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in dd2b1aba364ff9b05de41086f74407f285c57670 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -206,7 +206,7 @@ F src/os.h 60d419395e32a8029fa380a80a3da2e9030f635e F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c ae4b5240af4619d711301d7992396e182585269f -F src/os_win.c 648f842876e25391b7c454c8e49f7db1fd981d65 +F src/os_win.c a5b9ed90eed522925135f1cc5f0e737a624a6b5c F src/os_win.h 057344a6720b4c8405d9bd98f58cb37a6ee46c25 F src/pager.c f6bb1fa6cdf2062f2d8aec3e64db302bca519ab8 F src/pager.h ffd5607f7b3e4590b415b007a4382f693334d428 @@ -1173,7 +1173,10 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P b8b66103de8c554cb87df40bf040760ec29f2ae1 -R fb2228bf340b8e64476c0b547456f447 +P c405f971cf03e29110019ff863cbfb026d97e1e6 +R 80dc0ba2eb26692fe89f4430050446dd +T *branch * winLockHandle +T *sym-winLockHandle * +T -sym-trunk * U mistachkin -Z 33db4268ebdb5368353cf9e380a10aca +Z 89844ed2f261cecaceceb182643fd2e9 diff --git a/manifest.uuid b/manifest.uuid index a5c805d0f6..ec0e3fa20e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c405f971cf03e29110019ff863cbfb026d97e1e6 \ No newline at end of file +d43e2e59b5647655595fd953febf2beefa480006 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 21f633e486..eb7e87f431 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -2924,8 +2924,16 @@ static int winLock(sqlite3_file *id, int locktype){ ** If you are using this code as a model for alternative VFSes, do not ** copy this retry logic. It is a hack intended for Windows only. */ + lastErrno = osGetLastError(); OSTRACE(("LOCK-PENDING-FAIL file=%p, count=%d, result=%d\n", pFile->h, cnt, res)); + if( lastErrno==ERROR_INVALID_HANDLE ){ + pFile->lastErrno = lastErrno; + rc = SQLITE_IOERR_LOCK; + OSTRACE(("LOCK-FAIL file=%p, count=%d, rc=%s\n", + pFile->h, cnt, sqlite3ErrName(rc))); + return rc; + } if( cnt ) sqlite3_win32_sleep(1); } gotPendingLock = res; -- 2.47.2