mirror of
https://github.com/isar/libmdbx.git
synced 2024-10-30 11:29:19 +08:00
mdbx-windows: more for Wine.
Related to https://github.com/erthink/libmdbx/issues/83. UnlockFile() cold return ERROR_LOCK_VIOLATION when file not locked, instead of ERROR_NOT_LOCKED. Current versions of Wine seem to work correctly. Change-Id: Ibc5bd4352184efc7f88705e7ae04d6656286a96e
This commit is contained in:
parent
4fed2d9fc0
commit
289f2896d0
@ -367,22 +367,24 @@ mdbx_resume_threads_after_remap(mdbx_handle_array_t *array) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static void lck_unlock(MDBX_env *env) {
|
static void lck_unlock(MDBX_env *env) {
|
||||||
int rc;
|
int err;
|
||||||
|
|
||||||
if (env->me_lfd != INVALID_HANDLE_VALUE) {
|
if (env->me_lfd != INVALID_HANDLE_VALUE) {
|
||||||
/* double `unlock` for robustly remove overlapped shared/exclusive locks */
|
/* double `unlock` for robustly remove overlapped shared/exclusive locks */
|
||||||
while (funlock(env->me_lfd, LCK_LOWER))
|
while (funlock(env->me_lfd, LCK_LOWER))
|
||||||
;
|
;
|
||||||
rc = GetLastError();
|
err = GetLastError();
|
||||||
assert(rc == ERROR_NOT_LOCKED);
|
assert(err == ERROR_NOT_LOCKED ||
|
||||||
(void)rc;
|
(mdbx_RunningUnderWine() && err == ERROR_LOCK_VIOLATION));
|
||||||
|
(void)err;
|
||||||
SetLastError(ERROR_SUCCESS);
|
SetLastError(ERROR_SUCCESS);
|
||||||
|
|
||||||
while (funlock(env->me_lfd, LCK_UPPER))
|
while (funlock(env->me_lfd, LCK_UPPER))
|
||||||
;
|
;
|
||||||
rc = GetLastError();
|
err = GetLastError();
|
||||||
assert(rc == ERROR_NOT_LOCKED);
|
assert(err == ERROR_NOT_LOCKED ||
|
||||||
(void)rc;
|
(mdbx_RunningUnderWine() && err == ERROR_LOCK_VIOLATION));
|
||||||
|
(void)err;
|
||||||
SetLastError(ERROR_SUCCESS);
|
SetLastError(ERROR_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,23 +393,26 @@ static void lck_unlock(MDBX_env *env) {
|
|||||||
* releases such locks via deferred queues) */
|
* releases such locks via deferred queues) */
|
||||||
while (funlock(env->me_lazy_fd, LCK_BODY))
|
while (funlock(env->me_lazy_fd, LCK_BODY))
|
||||||
;
|
;
|
||||||
rc = GetLastError();
|
err = GetLastError();
|
||||||
assert(rc == ERROR_NOT_LOCKED);
|
assert(err == ERROR_NOT_LOCKED ||
|
||||||
(void)rc;
|
(mdbx_RunningUnderWine() && err == ERROR_LOCK_VIOLATION));
|
||||||
|
(void)err;
|
||||||
SetLastError(ERROR_SUCCESS);
|
SetLastError(ERROR_SUCCESS);
|
||||||
|
|
||||||
while (funlock(env->me_lazy_fd, LCK_META))
|
while (funlock(env->me_lazy_fd, LCK_META))
|
||||||
;
|
;
|
||||||
rc = GetLastError();
|
err = GetLastError();
|
||||||
assert(rc == ERROR_NOT_LOCKED);
|
assert(err == ERROR_NOT_LOCKED ||
|
||||||
(void)rc;
|
(mdbx_RunningUnderWine() && err == ERROR_LOCK_VIOLATION));
|
||||||
|
(void)err;
|
||||||
SetLastError(ERROR_SUCCESS);
|
SetLastError(ERROR_SUCCESS);
|
||||||
|
|
||||||
while (funlock(env->me_lazy_fd, LCK_WHOLE))
|
while (funlock(env->me_lazy_fd, LCK_WHOLE))
|
||||||
;
|
;
|
||||||
rc = GetLastError();
|
err = GetLastError();
|
||||||
assert(rc == ERROR_NOT_LOCKED);
|
assert(err == ERROR_NOT_LOCKED ||
|
||||||
(void)rc;
|
(mdbx_RunningUnderWine() && err == ERROR_LOCK_VIOLATION));
|
||||||
|
(void)err;
|
||||||
SetLastError(ERROR_SUCCESS);
|
SetLastError(ERROR_SUCCESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user