From 7935630197c5cf9bb297b0cb3d82a51e7a5a17e1 Mon Sep 17 00:00:00 2001 From: oktonion <0oktonion0@gmail.com> Date: Mon, 2 Mar 2020 11:01:52 +0300 Subject: [PATCH 1/3] fix of win file locks (classic return equal error) --- include/boost/interprocess/detail/os_file_functions.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/interprocess/detail/os_file_functions.hpp b/include/boost/interprocess/detail/os_file_functions.hpp index 0eeb26e..198392a 100644 --- a/include/boost/interprocess/detail/os_file_functions.hpp +++ b/include/boost/interprocess/detail/os_file_functions.hpp @@ -239,7 +239,7 @@ inline bool try_acquire_file_lock(file_handle_t hnd, bool &acquired) acquired = false, true : false; } - return (acquired = true); + return (true == acquired); } inline bool release_file_lock(file_handle_t hnd) @@ -268,7 +268,7 @@ inline bool try_acquire_file_lock_sharable(file_handle_t hnd, bool &acquired) return winapi::get_last_error() == winapi::error_lock_violation ? acquired = false, true : false; } - return (acquired = true); + return (true == acquired); } inline bool release_file_lock_sharable(file_handle_t hnd) From 771e849faecdd4136dcd2fcea8c463144a1cde2f Mon Sep 17 00:00:00 2001 From: oktonion <0oktonion0@gmail.com> Date: Mon, 2 Mar 2020 11:03:19 +0300 Subject: [PATCH 2/3] fix of WinAPI calls to (Un)LockFileEx for WinAPI (Un)LockFileEx reserved value should always be zero, no matter what --- include/boost/interprocess/detail/win32_api.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/boost/interprocess/detail/win32_api.hpp b/include/boost/interprocess/detail/win32_api.hpp index 4761713..38b5187 100644 --- a/include/boost/interprocess/detail/win32_api.hpp +++ b/include/boost/interprocess/detail/win32_api.hpp @@ -1454,11 +1454,11 @@ inline bool set_file_pointer_ex(void *handle, __int64 distance, __int64 *new_fil return 0 != SetFilePointerEx(handle, d, (large_integer*)new_file_pointer, move_method); } -inline bool lock_file_ex(void *hnd, unsigned long flags, unsigned long reserved, unsigned long size_low, unsigned long size_high, interprocess_overlapped *overlapped) -{ return 0 != LockFileEx(hnd, flags, reserved, size_low, size_high, overlapped); } +inline bool lock_file_ex(void *hnd, unsigned long flags, unsigned long, unsigned long size_low, unsigned long size_high, interprocess_overlapped *overlapped) +{ return 0 != LockFileEx(hnd, flags, 0, size_low, size_high, overlapped); } -inline bool unlock_file_ex(void *hnd, unsigned long reserved, unsigned long size_low, unsigned long size_high, interprocess_overlapped *overlapped) -{ return 0 != UnlockFileEx(hnd, reserved, size_low, size_high, overlapped); } +inline bool unlock_file_ex(void *hnd, unsigned long, unsigned long size_low, unsigned long size_high, interprocess_overlapped *overlapped) +{ return 0 != UnlockFileEx(hnd, 0, size_low, size_high, overlapped); } inline bool write_file(void *hnd, const void *buffer, unsigned long bytes_to_write, unsigned long *bytes_written, interprocess_overlapped* overlapped) { return 0 != WriteFile(hnd, buffer, bytes_to_write, bytes_written, overlapped); } From 6586572759086e4a0ca049334cb6187129c01380 Mon Sep 17 00:00:00 2001 From: oktonion <0oktonion0@gmail.com> Date: Mon, 2 Mar 2020 11:17:27 +0300 Subject: [PATCH 3/3] enhancing of win file locks makes returns clear to understand elimintes compiler warnings --- include/boost/interprocess/detail/os_file_functions.hpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/boost/interprocess/detail/os_file_functions.hpp b/include/boost/interprocess/detail/os_file_functions.hpp index 198392a..2cf56dd 100644 --- a/include/boost/interprocess/detail/os_file_functions.hpp +++ b/include/boost/interprocess/detail/os_file_functions.hpp @@ -239,7 +239,8 @@ inline bool try_acquire_file_lock(file_handle_t hnd, bool &acquired) acquired = false, true : false; } - return (true == acquired); + acquired = true; + return true; } inline bool release_file_lock(file_handle_t hnd) @@ -268,7 +269,9 @@ inline bool try_acquire_file_lock_sharable(file_handle_t hnd, bool &acquired) return winapi::get_last_error() == winapi::error_lock_violation ? acquired = false, true : false; } - return (true == acquired); + + acquired = true; + return true; } inline bool release_file_lock_sharable(file_handle_t hnd)