summaryrefslogtreecommitdiffstats
path: root/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp')
-rw-r--r--lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp49
1 files changed, 19 insertions, 30 deletions
diff --git a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
index a2d99f166d0..dbbd5a1dcc3 100644
--- a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -411,8 +411,7 @@ ConnectionFileDescriptor::Disconnect(Error *error_ptr)
}
size_t
-ConnectionFileDescriptor::Read(void *dst, size_t dst_len, uint32_t timeout_usec, bool read_full_buffer,
- ConnectionStatus &status, Error *error_ptr)
+ConnectionFileDescriptor::Read(void *dst, size_t dst_len, uint32_t timeout_usec, ConnectionStatus &status, Error *error_ptr)
{
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
@@ -435,36 +434,26 @@ ConnectionFileDescriptor::Read(void *dst, size_t dst_len, uint32_t timeout_usec,
return 0;
}
- size_t total_bytes_read = 0;
- char *dst_buf = static_cast<char *>(dst);
- auto now = std::chrono::steady_clock::now();
- const auto deadline = now + std::chrono::microseconds(timeout_usec);
+ status = BytesAvailable(timeout_usec, error_ptr);
+ if (status != eConnectionStatusSuccess)
+ return 0;
+
Error error;
- do
+ size_t bytes_read = dst_len;
+ error = m_read_sp->Read(dst, bytes_read);
+
+ if (log)
{
- timeout_usec = std::chrono::duration_cast<std::chrono::microseconds>(deadline - now).count();
- status = BytesAvailable(timeout_usec, error_ptr);
- if (status != eConnectionStatusSuccess)
- return 0;
+ log->Printf("%p ConnectionFileDescriptor::Read() fd = %" PRIu64 ", dst = %p, dst_len = %" PRIu64 ") => %" PRIu64 ", error = %s",
+ static_cast<void *>(this), static_cast<uint64_t>(m_read_sp->GetWaitableHandle()), static_cast<void *>(dst),
+ static_cast<uint64_t>(dst_len), static_cast<uint64_t>(bytes_read), error.AsCString());
+ }
- size_t bytes_read = dst_len - total_bytes_read;
- error = m_read_sp->Read(dst_buf + total_bytes_read, bytes_read);
- if (log)
- {
- log->Printf("%p ConnectionFileDescriptor::Read() fd = %" PRIu64 ", dst = %p, dst_len = %" PRIu64
- ") => %" PRIu64 ", error = %s",
- this, static_cast<uint64_t>(m_read_sp->GetWaitableHandle()), dst,
- static_cast<uint64_t>(dst_len), static_cast<uint64_t>(bytes_read), error.AsCString());
- }
- total_bytes_read += bytes_read;
- if (bytes_read == 0)
- {
- // End-of-file. Do not automatically close; pass along for the end-of-file handlers.
- error.Clear();
- status = eConnectionStatusEndOfFile;
- }
- now = std::chrono::steady_clock::now();
- } while (read_full_buffer && total_bytes_read < dst_len && status == eConnectionStatusSuccess && now < deadline);
+ if (bytes_read == 0)
+ {
+ error.Clear(); // End-of-file. Do not automatically close; pass along for the end-of-file handlers.
+ status = eConnectionStatusEndOfFile;
+ }
if (error_ptr)
*error_ptr = error;
@@ -520,7 +509,7 @@ ConnectionFileDescriptor::Read(void *dst, size_t dst_len, uint32_t timeout_usec,
return 0;
}
- return total_bytes_read;
+ return bytes_read;
}
size_t
OpenPOWER on IntegriCloud