summaryrefslogtreecommitdiff
path: root/source/Host/posix/ConnectionFileDescriptorPosix.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Host/posix/ConnectionFileDescriptorPosix.cpp')
-rw-r--r--source/Host/posix/ConnectionFileDescriptorPosix.cpp32
1 files changed, 13 insertions, 19 deletions
diff --git a/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/source/Host/posix/ConnectionFileDescriptorPosix.cpp
index deac3844d4a2..067e85972eca 100644
--- a/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ b/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -1,9 +1,8 @@
//===-- ConnectionFileDescriptorPosix.cpp -----------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -32,6 +31,7 @@
#include <unistd.h>
#endif
+#include <memory>
#include <sstream>
#include "llvm/Support/Errno.h"
@@ -87,8 +87,8 @@ ConnectionFileDescriptor::ConnectionFileDescriptor(bool child_processes_inherit)
ConnectionFileDescriptor::ConnectionFileDescriptor(int fd, bool owns_fd)
: Connection(), m_pipe(), m_mutex(), m_shutting_down(false),
m_waiting_for_accept(false), m_child_processes_inherit(false) {
- m_write_sp.reset(new File(fd, owns_fd));
- m_read_sp.reset(new File(fd, false));
+ m_write_sp = std::make_shared<File>(fd, owns_fd);
+ m_read_sp = std::make_shared<File>(fd, false);
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION |
LIBLLDB_LOG_OBJECT));
@@ -111,7 +111,7 @@ ConnectionFileDescriptor::~ConnectionFileDescriptor() {
if (log)
log->Printf("%p ConnectionFileDescriptor::~ConnectionFileDescriptor ()",
static_cast<void *>(this));
- Disconnect(NULL);
+ Disconnect(nullptr);
CloseCommandPipe();
}
@@ -222,8 +222,8 @@ ConnectionStatus ConnectionFileDescriptor::Connect(llvm::StringRef path,
m_read_sp = std::move(tcp_socket);
m_write_sp = m_read_sp;
} else {
- m_read_sp.reset(new File(fd, false));
- m_write_sp.reset(new File(fd, false));
+ m_read_sp = std::make_shared<File>(fd, false);
+ m_write_sp = std::make_shared<File>(fd, false);
}
m_uri = *addr;
return eConnectionStatusSuccess;
@@ -262,7 +262,7 @@ ConnectionStatus ConnectionFileDescriptor::Connect(llvm::StringRef path,
options.c_cc[VMIN] = 1;
options.c_cc[VTIME] = 0;
- ::tcsetattr(fd, TCSANOW, &options);
+ llvm::sys::RetryAfterSignal(-1, ::tcsetattr, fd, TCSANOW, &options);
}
int flags = ::fcntl(fd, F_GETFL, 0);
@@ -272,8 +272,8 @@ ConnectionStatus ConnectionFileDescriptor::Connect(llvm::StringRef path,
::fcntl(fd, F_SETFL, flags);
}
}
- m_read_sp.reset(new File(fd, true));
- m_write_sp.reset(new File(fd, false));
+ m_read_sp = std::make_shared<File>(fd, true);
+ m_write_sp = std::make_shared<File>(fd, false);
return eConnectionStatusSuccess;
}
#endif
@@ -758,13 +758,7 @@ void ConnectionFileDescriptor::SetChildProcessesInherit(
}
void ConnectionFileDescriptor::InitializeSocket(Socket *socket) {
- assert(socket->GetSocketProtocol() == Socket::ProtocolTcp);
- TCPSocket *tcp_socket = static_cast<TCPSocket *>(socket);
-
m_write_sp.reset(socket);
m_read_sp = m_write_sp;
- StreamString strm;
- strm.Printf("connect://%s:%u", tcp_socket->GetRemoteIPAddress().c_str(),
- tcp_socket->GetRemotePortNumber());
- m_uri = strm.GetString();
+ m_uri = socket->GetRemoteConnectionURI();
}