aboutsummaryrefslogtreecommitdiff
path: root/source/Host/windows/ConnectionGenericFileWindows.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Host/windows/ConnectionGenericFileWindows.cpp')
-rw-r--r--source/Host/windows/ConnectionGenericFileWindows.cpp44
1 files changed, 18 insertions, 26 deletions
diff --git a/source/Host/windows/ConnectionGenericFileWindows.cpp b/source/Host/windows/ConnectionGenericFileWindows.cpp
index 41bdb5f41fb6..e59e190dcb2d 100644
--- a/source/Host/windows/ConnectionGenericFileWindows.cpp
+++ b/source/Host/windows/ConnectionGenericFileWindows.cpp
@@ -21,12 +21,10 @@ using namespace lldb_private;
namespace {
// This is a simple helper class to package up the information needed to return
-// from a Read/Write
-// operation function. Since there is a lot of code to be run before exit
-// regardless of whether the
-// operation succeeded or failed, combined with many possible return paths, this
-// is the cleanest
-// way to represent it.
+// from a Read/Write operation function. Since there is a lot of code to be
+// run before exit regardless of whether the operation succeeded or failed,
+// combined with many possible return paths, this is the cleanest way to
+// represent it.
class ReturnInfo {
public:
void Set(size_t bytes, ConnectionStatus status, DWORD error_code) {
@@ -78,11 +76,9 @@ void ConnectionGenericFile::InitializeEventHandles() {
m_event_handles[kInterruptEvent] = CreateEvent(NULL, FALSE, FALSE, NULL);
// Note, we should use a manual reset event for the hEvent argument of the
- // OVERLAPPED. This
- // is because both WaitForMultipleObjects and GetOverlappedResult (if you set
- // the bWait
- // argument to TRUE) will wait for the event to be signalled. If we use an
- // auto-reset event,
+ // OVERLAPPED. This is because both WaitForMultipleObjects and
+ // GetOverlappedResult (if you set the bWait argument to TRUE) will wait for
+ // the event to be signalled. If we use an auto-reset event,
// WaitForMultipleObjects will reset the event, return successfully, and then
// GetOverlappedResult will block since the event is no longer signalled.
m_event_handles[kBytesAvailableEvent] =
@@ -147,8 +143,7 @@ lldb::ConnectionStatus ConnectionGenericFile::Disconnect(Status *error_ptr) {
return eConnectionStatusSuccess;
// Reset the handle so that after we unblock any pending reads, subsequent
- // calls to Read() will
- // see a disconnected state.
+ // calls to Read() will see a disconnected state.
HANDLE old_file = m_file;
m_file = INVALID_HANDLE_VALUE;
@@ -157,8 +152,7 @@ lldb::ConnectionStatus ConnectionGenericFile::Disconnect(Status *error_ptr) {
::CancelIoEx(old_file, &m_overlapped);
// Close the file handle if we owned it, but don't close the event handles.
- // We could always
- // reconnect with the same Connection instance.
+ // We could always reconnect with the same Connection instance.
if (m_owns_file)
::CloseHandle(old_file);
@@ -190,8 +184,7 @@ size_t ConnectionGenericFile::Read(void *dst, size_t dst_len,
if (result || ::GetLastError() == ERROR_IO_PENDING) {
if (!result) {
// The expected return path. The operation is pending. Wait for the
- // operation to complete
- // or be interrupted.
+ // operation to complete or be interrupted.
DWORD milliseconds =
timeout
? std::chrono::duration_cast<std::chrono::milliseconds>(*timeout)
@@ -219,11 +212,9 @@ size_t ConnectionGenericFile::Read(void *dst, size_t dst_len,
// The data is ready. Figure out how much was read and return;
if (!::GetOverlappedResult(m_file, &m_overlapped, &bytes_read, FALSE)) {
DWORD result_error = ::GetLastError();
- // ERROR_OPERATION_ABORTED occurs when someone calls Disconnect() during a
- // blocking read.
- // This triggers a call to CancelIoEx, which causes the operation to
- // complete and the
- // result to be ERROR_OPERATION_ABORTED.
+ // ERROR_OPERATION_ABORTED occurs when someone calls Disconnect() during
+ // a blocking read. This triggers a call to CancelIoEx, which causes the
+ // operation to complete and the result to be ERROR_OPERATION_ABORTED.
if (result_error == ERROR_HANDLE_EOF ||
result_error == ERROR_OPERATION_ABORTED ||
result_error == ERROR_BROKEN_PIPE)
@@ -250,9 +241,9 @@ finish:
if (error_ptr)
*error_ptr = return_info.GetError();
- // kBytesAvailableEvent is a manual reset event. Make sure it gets reset here
- // so that any
- // subsequent operations don't immediately see bytes available.
+ // kBytesAvailableEvent is a manual reset event. Make sure it gets reset
+ // here so that any subsequent operations don't immediately see bytes
+ // available.
ResetEvent(m_event_handles[kBytesAvailableEvent]);
IncrementFilePointer(return_info.GetBytes());
@@ -284,7 +275,8 @@ size_t ConnectionGenericFile::Write(const void *src, size_t src_len,
m_overlapped.hEvent = NULL;
- // Writes are not interruptible like reads are, so just block until it's done.
+ // Writes are not interruptible like reads are, so just block until it's
+ // done.
result = ::WriteFile(m_file, src, src_len, NULL, &m_overlapped);
if (!result && ::GetLastError() != ERROR_IO_PENDING) {
return_info.Set(0, eConnectionStatusError, ::GetLastError());