diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 20:51:52 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 20:51:52 +0000 |
commit | 5f29bb8a675e8f96452b632e7129113f7dec850e (patch) | |
tree | 3d3f2a0d3ad10872a4dcaba8ec8d1d20c87ab147 /source/Host/posix/ConnectionFileDescriptorPosix.cpp | |
parent | 88c643b6fec27eec436c8d138fee6346e92337d6 (diff) |
Notes
Diffstat (limited to 'source/Host/posix/ConnectionFileDescriptorPosix.cpp')
-rw-r--r-- | source/Host/posix/ConnectionFileDescriptorPosix.cpp | 32 |
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(); } |