diff options
author | Lawrence D'Anna <lawrence_danna@apple.com> | 2019-09-27 20:43:50 +0000 |
---|---|---|
committer | Lawrence D'Anna <lawrence_danna@apple.com> | 2019-09-27 20:43:50 +0000 |
commit | 117512715d66f613b9eb9016725e5c3591f4f9df (patch) | |
tree | 7a7913626084e72eed9c5d8eb2c7eb1619212880 /lldb/source/Host | |
parent | 121ef04f04ae1b944d85d249bc337555c9cef4ec (diff) | |
download | bcm5719-llvm-117512715d66f613b9eb9016725e5c3591f4f9df.tar.gz bcm5719-llvm-117512715d66f613b9eb9016725e5c3591f4f9df.zip |
refactor: move IOObject::m_should_close_fd into subclasses
Summary:
m_should_close_fd doesn't need to be in IOObject. It will be useful
for my next change to move it down into File and Socket.
Reviewers: labath, JDevlieghere, jasonmolenda
Reviewed By: JDevlieghere
Subscribers: lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D68152
llvm-svn: 373126
Diffstat (limited to 'lldb/source/Host')
-rw-r--r-- | lldb/source/Host/common/File.cpp | 10 | ||||
-rw-r--r-- | lldb/source/Host/common/Socket.cpp | 5 |
2 files changed, 8 insertions, 7 deletions
diff --git a/lldb/source/Host/common/File.cpp b/lldb/source/Host/common/File.cpp index 7560f1d2752..70e0507d185 100644 --- a/lldb/source/Host/common/File.cpp +++ b/lldb/source/Host/common/File.cpp @@ -98,7 +98,7 @@ FILE *File::GetStream() { if (DescriptorIsValid()) { const char *mode = GetStreamOpenModeFromOptions(m_options); if (mode) { - if (!m_should_close_fd) { + if (!m_own_descriptor) { // We must duplicate the file descriptor if we don't own it because when you // call fdopen, the stream will own the fd #ifdef _WIN32 @@ -106,7 +106,7 @@ FILE *File::GetStream() { #else m_descriptor = dup(GetDescriptor()); #endif - m_should_close_fd = true; + m_own_descriptor = true; } m_stream = @@ -117,7 +117,7 @@ FILE *File::GetStream() { if (m_stream) { m_own_stream = true; - m_should_close_fd = false; + m_own_descriptor = false; } } } @@ -148,7 +148,7 @@ Status File::Close() { error.SetErrorToErrno(); } - if (DescriptorIsValid() && m_should_close_fd) { + if (DescriptorIsValid() && m_own_descriptor) { if (::close(m_descriptor) != 0) error.SetErrorToErrno(); } @@ -156,7 +156,7 @@ Status File::Close() { m_stream = kInvalidStream; m_options = 0; m_own_stream = false; - m_should_close_fd = false; + m_own_descriptor = false; m_is_interactive = eLazyBoolCalculate; m_is_real_terminal = eLazyBoolCalculate; return error; diff --git a/lldb/source/Host/common/Socket.cpp b/lldb/source/Host/common/Socket.cpp index 237688519f7..6358ab8a8e7 100644 --- a/lldb/source/Host/common/Socket.cpp +++ b/lldb/source/Host/common/Socket.cpp @@ -74,9 +74,10 @@ bool IsInterrupted() { Socket::Socket(SocketProtocol protocol, bool should_close, bool child_processes_inherit) - : IOObject(eFDTypeSocket, should_close), m_protocol(protocol), + : IOObject(eFDTypeSocket), m_protocol(protocol), m_socket(kInvalidSocketValue), - m_child_processes_inherit(child_processes_inherit) {} + m_child_processes_inherit(child_processes_inherit), + m_should_close_fd(should_close) {} Socket::~Socket() { Close(); } |