From 50e9e0e561555c849ed3373f82e3e4abd29523ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D0=BE=D0=BD=D0=B8=D0=B4=20=D0=AE=D1=80=D1=8C?= =?UTF-8?q?=D0=B5=D0=B2=20=28Leonid=20Yuriev=29?= Date: Wed, 12 Oct 2022 18:00:05 +0300 Subject: [PATCH] mdbx-windows: drop needless `LockFileEx()` inside `mdbx_env_copy()` (backport). --- src/core.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/core.c b/src/core.c index 71dee172..881b9380 100644 --- a/src/core.c +++ b/src/core.c @@ -19853,14 +19853,10 @@ __cold int mdbx_env_copy(MDBX_env *env, const char *dest_path, #endif ); - if (rc == MDBX_SUCCESS) { #if defined(_WIN32) || defined(_WIN64) - OVERLAPPED ov; - memset(&ov, 0, sizeof(ov)); - if (!LockFileEx(newfd, LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY, - 0, 0, INT32_MAX, &ov)) - rc = GetLastError(); + /* no locking required since the file opened with ShareMode == 0 */ #else + if (rc == MDBX_SUCCESS) { struct flock lock_op; memset(&lock_op, 0, sizeof(lock_op)); lock_op.l_type = F_WRLCK; @@ -19875,8 +19871,8 @@ __cold int mdbx_env_copy(MDBX_env *env, const char *dest_path, #endif /* Linux */ ) rc = errno; -#endif /* Windows / POSIX */ } +#endif /* Windows / POSIX */ if (rc == MDBX_SUCCESS) rc = mdbx_env_copy2fd(env, newfd, flags);