llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-lldb Author: Charles Zablit (charles-zablit) <details> <summary>Changes</summary> If a read is interrupted in `ConnectionGenericFile::Read`, the data that has already been read by `ReadFile` is lost. This patch adds `m_read_pending` to mark a read as interrupted. The next read will pick up the results of the previous read and return the number of `bytes_read`. --- Full diff: https://github.com/llvm/llvm-project/pull/182536.diff 2 Files Affected: - (modified) lldb/include/lldb/Host/windows/ConnectionGenericFileWindows.h (+1) - (modified) lldb/source/Host/windows/ConnectionGenericFileWindows.cpp (+10) ``````````diff diff --git a/lldb/include/lldb/Host/windows/ConnectionGenericFileWindows.h b/lldb/include/lldb/Host/windows/ConnectionGenericFileWindows.h index d8f06a7162b22..62ac1bb35c9f8 100644 --- a/lldb/include/lldb/Host/windows/ConnectionGenericFileWindows.h +++ b/lldb/include/lldb/Host/windows/ConnectionGenericFileWindows.h @@ -43,6 +43,7 @@ class ConnectionGenericFile : public lldb_private::Connection { protected: OVERLAPPED m_overlapped; + bool m_read_pending = false; HANDLE m_file; HANDLE m_event_handles[2]; bool m_owns_file; diff --git a/lldb/source/Host/windows/ConnectionGenericFileWindows.cpp b/lldb/source/Host/windows/ConnectionGenericFileWindows.cpp index 6a6153d6e34a0..28727c82f6e37 100644 --- a/lldb/source/Host/windows/ConnectionGenericFileWindows.cpp +++ b/lldb/source/Host/windows/ConnectionGenericFileWindows.cpp @@ -176,9 +176,17 @@ size_t ConnectionGenericFile::Read(void *dst, size_t dst_len, goto finish; } + if (m_read_pending) { + if (::GetOverlappedResult(m_file, &m_overlapped, &bytes_read, FALSE)) { + m_read_pending = false; + return bytes_read; + } + } + m_overlapped.hEvent = m_event_handles[kBytesAvailableEvent]; result = ::ReadFile(m_file, dst, dst_len, NULL, &m_overlapped); + m_read_pending = true; if (result || ::GetLastError() == ERROR_IO_PENDING) { if (!result) { // The expected return path. The operation is pending. Wait for the @@ -234,6 +242,8 @@ size_t ConnectionGenericFile::Read(void *dst, size_t dst_len, goto finish; finish: + if (return_info.GetStatus() != eConnectionStatusInterrupted) + m_read_pending = false; status = return_info.GetStatus(); if (error_ptr) *error_ptr = return_info.GetError().Clone(); `````````` </details> https://github.com/llvm/llvm-project/pull/182536 _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
