mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Minor cleanup and refactoring of the Win32 VFS for lsm1.
FossilOrigin-Name: bf7eda67c8124c3cd5d9150f2f2694cd3f991b20e0a527398885976d0d787242
This commit is contained in:
@ -587,22 +587,27 @@ static int lsmWin32OsUnlink(lsm_env *pEnv, const char *zFile){
|
||||
((a)==ERROR_IO_PENDING))
|
||||
#endif
|
||||
|
||||
static int lsmWin32OsLock(lsm_file *pFile, int iLock, int eType){
|
||||
Win32File *pWin32File = (Win32File *)pFile;
|
||||
static int win32LockFile(
|
||||
Win32File *pWin32File,
|
||||
int iLock,
|
||||
int nLock,
|
||||
int eType
|
||||
){
|
||||
OVERLAPPED ovlp;
|
||||
|
||||
assert( LSM_LOCK_UNLOCK==0 );
|
||||
assert( LSM_LOCK_SHARED==1 );
|
||||
assert( LSM_LOCK_EXCL==2 );
|
||||
assert( eType>=LSM_LOCK_UNLOCK && eType<=LSM_LOCK_EXCL );
|
||||
assert( nLock>=0 );
|
||||
assert( iLock>0 && iLock<=32 );
|
||||
|
||||
memset(&ovlp, 0, sizeof(OVERLAPPED));
|
||||
ovlp.Offset = (4096-iLock);
|
||||
ovlp.Offset = (4096-iLock-nLock+1);
|
||||
if( eType>LSM_LOCK_UNLOCK ){
|
||||
DWORD flags = LOCKFILE_FAIL_IMMEDIATELY;
|
||||
if( eType>=LSM_LOCK_EXCL ) flags |= LOCKFILE_EXCLUSIVE_LOCK;
|
||||
if( !LockFileEx(pWin32File->hFile, flags, 0, 1, 0, &ovlp) ){
|
||||
if( !LockFileEx(pWin32File->hFile, flags, 0, (DWORD)nLock, 0, &ovlp) ){
|
||||
if( win32IsLockBusy(GetLastError()) ){
|
||||
return LSM_BUSY;
|
||||
}else{
|
||||
@ -610,36 +615,24 @@ static int lsmWin32OsLock(lsm_file *pFile, int iLock, int eType){
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if( !UnlockFileEx(pWin32File->hFile, 0, 1, 0, &ovlp) ){
|
||||
if( !UnlockFileEx(pWin32File->hFile, 0, (DWORD)nLock, 0, &ovlp) ){
|
||||
return LSM_IOERR_BKPT;
|
||||
}
|
||||
}
|
||||
return LSM_OK;
|
||||
}
|
||||
|
||||
static int lsmWin32OsTestLock(lsm_file *pFile, int iLock, int nLock, int eType){
|
||||
static int lsmWin32OsLock(lsm_file *pFile, int iLock, int eType){
|
||||
Win32File *pWin32File = (Win32File *)pFile;
|
||||
DWORD flags = LOCKFILE_FAIL_IMMEDIATELY;
|
||||
OVERLAPPED ovlp;
|
||||
return win32LockFile(pWin32File, iLock, 1, eType);
|
||||
}
|
||||
|
||||
assert( LSM_LOCK_UNLOCK==0 );
|
||||
assert( LSM_LOCK_SHARED==1 );
|
||||
assert( LSM_LOCK_EXCL==2 );
|
||||
assert( eType==LSM_LOCK_SHARED || eType==LSM_LOCK_EXCL );
|
||||
assert( nLock>=0 );
|
||||
assert( iLock>0 && iLock<=32 );
|
||||
|
||||
if( eType>=LSM_LOCK_EXCL ) flags |= LOCKFILE_EXCLUSIVE_LOCK;
|
||||
memset(&ovlp, 0, sizeof(OVERLAPPED));
|
||||
ovlp.Offset = (4096-iLock-nLock+1);
|
||||
if( !LockFileEx(pWin32File->hFile, flags, 0, (DWORD)nLock, 0, &ovlp) ){
|
||||
if( win32IsLockBusy(GetLastError()) ){
|
||||
return LSM_BUSY;
|
||||
}else{
|
||||
return LSM_IOERR_BKPT;
|
||||
}
|
||||
}
|
||||
UnlockFileEx(pWin32File->hFile, 0, (DWORD)nLock, 0, &ovlp);
|
||||
static int lsmWin32OsTestLock(lsm_file *pFile, int iLock, int nLock, int eType){
|
||||
int rc;
|
||||
Win32File *pWin32File = (Win32File *)pFile;
|
||||
rc = win32LockFile(pWin32File, iLock, nLock, eType);
|
||||
if( rc!=LSM_OK ) return rc;
|
||||
win32LockFile(pWin32File, iLock, nLock, LSM_LOCK_UNLOCK);
|
||||
return LSM_OK;
|
||||
}
|
||||
|
||||
|
14
manifest
14
manifest
@ -1,5 +1,5 @@
|
||||
C Another\sspelling\serror\sin\sthe\sREADME.md\sfile.
|
||||
D 2017-07-10T19:54:48.282
|
||||
C Minor\scleanup\sand\srefactoring\sof\sthe\sWin32\sVFS\sfor\slsm1.
|
||||
D 2017-07-10T20:33:50.763
|
||||
F Makefile.in 081e48dfe7f995d57ce1a88ddf4d2917b4349158648a6cd45b42beae30de3a12
|
||||
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
||||
F Makefile.msc 20850e3e8d4d4791e0531955852d768eb06f24138214870d543abb1a47346fba
|
||||
@ -250,7 +250,7 @@ F ext/lsm1/lsm_tree.c 53b657439e0fcb1117b0559ad3567ac417f81f2ed0fff9bab79948a00e
|
||||
F ext/lsm1/lsm_unix.c 57361bcf5b1a1a028f5d66571ee490e9064d2cfb145a2cc9e5ddade467bb551b
|
||||
F ext/lsm1/lsm_varint.c b19ae9bd26b5a1e8402fb8a564b25d9542338a41
|
||||
F ext/lsm1/lsm_vtab.c 812b74a9a7539e8cab49761591ffddc1b3580735fac5d638826c8d2be95ff38b
|
||||
F ext/lsm1/lsm_win32.c 646b20f966e834bbf91ce763050bd6cf2732095b8165e6b1f09da22493149bc5
|
||||
F ext/lsm1/lsm_win32.c 515f8298982e0e8aa7c6677389ffc66c65a5ff294baf678eefa19b6e61c239c3
|
||||
F ext/misc/README.md 8e008c8d2b02e09096b31dfba033253ac27c6c06a18aa5826e299fa7601d90b2
|
||||
F ext/misc/amatch.c 6db4607cb17c54b853a2d7c7c36046d004853f65b9b733e6f019d543d5dfae87
|
||||
F ext/misc/anycollseq.c 5ffdfde9829eeac52219136ad6aa7cd9a4edb3b15f4f2532de52f4a22525eddb
|
||||
@ -1628,7 +1628,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P 12bc47c50252f1307b224d171069b93192d0c905aadf480829bba390c059aee4
|
||||
R 760b18f77d254e39c1233bdd5abb0ed8
|
||||
U drh
|
||||
Z 78eeda4b1b2ef6d92a2436796c56cbe3
|
||||
P 0512937425df6f274153f1d822fc4fe358601c2944745c0039c40e645ebedd82
|
||||
R 23297e96404b1121c3ff346849386fe8
|
||||
U mistachkin
|
||||
Z 580805a1ed03998ae70db1e05b484fcc
|
||||
|
@ -1 +1 @@
|
||||
0512937425df6f274153f1d822fc4fe358601c2944745c0039c40e645ebedd82
|
||||
bf7eda67c8124c3cd5d9150f2f2694cd3f991b20e0a527398885976d0d787242
|
Reference in New Issue
Block a user