Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/llfio.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'include/llfio/v2.0/detail/impl/windows/io_handle.ipp')
-rw-r--r--include/llfio/v2.0/detail/impl/windows/io_handle.ipp84
1 files changed, 0 insertions, 84 deletions
diff --git a/include/llfio/v2.0/detail/impl/windows/io_handle.ipp b/include/llfio/v2.0/detail/impl/windows/io_handle.ipp
index 359c7573..4ae8a9fe 100644
--- a/include/llfio/v2.0/detail/impl/windows/io_handle.ipp
+++ b/include/llfio/v2.0/detail/impl/windows/io_handle.ipp
@@ -133,88 +133,4 @@ io_handle::io_result<io_handle::const_buffers_type> io_handle::write(io_handle::
return do_read_write(_v, &WriteFile, reqs, d);
}
-result<io_handle::extent_guard> io_handle::lock(io_handle::extent_type offset, io_handle::extent_type bytes, bool exclusive, deadline d) noexcept
-{
- LLFIO_LOG_FUNCTION_CALL(_v.h);
- if(d && d.nsecs > 0 && !_v.is_overlapped())
- {
- return errc::not_supported;
- }
- DWORD flags = exclusive ? LOCKFILE_EXCLUSIVE_LOCK : 0;
- if(d && (d.nsecs == 0u))
- {
- flags |= LOCKFILE_FAIL_IMMEDIATELY;
- }
- LLFIO_WIN_DEADLINE_TO_SLEEP_INIT(d);
- OVERLAPPED ol{};
- memset(&ol, 0, sizeof(ol));
- ol.Internal = static_cast<ULONG_PTR>(-1);
- ol.OffsetHigh = (offset >> 32) & 0xffffffff;
- ol.Offset = offset & 0xffffffff;
- DWORD bytes_high = bytes == 0u ? MAXDWORD : static_cast<DWORD>((bytes >> 32) & 0xffffffff);
- DWORD bytes_low = bytes == 0u ? MAXDWORD : static_cast<DWORD>(bytes & 0xffffffff);
- if(LockFileEx(_v.h, flags, 0, bytes_low, bytes_high, &ol) == 0)
- {
- if(ERROR_LOCK_VIOLATION == GetLastError() && d && (d.nsecs == 0u))
- {
- return errc::timed_out;
- }
- if(ERROR_IO_PENDING != GetLastError())
- {
- return win32_error();
- }
- }
- // If handle is overlapped, wait for completion of each i/o.
- if(_v.is_overlapped())
- {
- if(STATUS_TIMEOUT == ntwait(_v.h, ol, d))
- {
- LLFIO_WIN_DEADLINE_TO_TIMEOUT(d);
- }
- // It seems the NT kernel is guilty of casting bugs sometimes
- ol.Internal = ol.Internal & 0xffffffff;
- if(ol.Internal != 0)
- {
- return ntkernel_error(static_cast<NTSTATUS>(ol.Internal));
- }
- }
- return extent_guard(this, offset, bytes, exclusive);
-}
-
-void io_handle::unlock(io_handle::extent_type offset, io_handle::extent_type bytes) noexcept
-{
- LLFIO_LOG_FUNCTION_CALL(this);
- OVERLAPPED ol{};
- memset(&ol, 0, sizeof(ol));
- ol.Internal = static_cast<ULONG_PTR>(-1);
- ol.OffsetHigh = (offset >> 32) & 0xffffffff;
- ol.Offset = offset & 0xffffffff;
- DWORD bytes_high = bytes == 0u ? MAXDWORD : static_cast<DWORD>((bytes >> 32) & 0xffffffff);
- DWORD bytes_low = bytes == 0u ? MAXDWORD : static_cast<DWORD>(bytes & 0xffffffff);
- if(UnlockFileEx(_v.h, 0, bytes_low, bytes_high, &ol) == 0)
- {
- if(ERROR_IO_PENDING != GetLastError())
- {
- auto ret = win32_error();
- (void) ret;
- LLFIO_LOG_FATAL(_v.h, "io_handle::unlock() failed");
- std::terminate();
- }
- }
- // If handle is overlapped, wait for completion of each i/o.
- if(_v.is_overlapped())
- {
- ntwait(_v.h, ol, deadline());
- if(ol.Internal != 0)
- {
- // It seems the NT kernel is guilty of casting bugs sometimes
- ol.Internal = ol.Internal & 0xffffffff;
- auto ret = ntkernel_error(static_cast<NTSTATUS>(ol.Internal));
- (void) ret;
- LLFIO_LOG_FATAL(_v.h, "io_handle::unlock() failed");
- std::terminate();
- }
- }
-}
-
LLFIO_V2_NAMESPACE_END