summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/Host/File.h18
-rw-r--r--lldb/include/lldb/Host/Socket.h1
-rw-r--r--lldb/include/lldb/Utility/IOObject.h5
-rw-r--r--lldb/source/Host/common/File.cpp10
-rw-r--r--lldb/source/Host/common/Socket.cpp5
5 files changed, 20 insertions, 19 deletions
diff --git a/lldb/include/lldb/Host/File.h b/lldb/include/lldb/Host/File.h
index 612266f0a5a..767d631672c 100644
--- a/lldb/include/lldb/Host/File.h
+++ b/lldb/include/lldb/Host/File.h
@@ -51,22 +51,23 @@ public:
static mode_t ConvertOpenOptionsForPOSIXOpen(uint32_t open_options);
File()
- : IOObject(eFDTypeFile, false), m_descriptor(kInvalidDescriptor),
- m_stream(kInvalidStream), m_options(0), m_own_stream(false),
- m_is_interactive(eLazyBoolCalculate),
+ : IOObject(eFDTypeFile), m_descriptor(kInvalidDescriptor),
+ m_own_descriptor(false), m_stream(kInvalidStream), m_options(0),
+ m_own_stream(false), m_is_interactive(eLazyBoolCalculate),
m_is_real_terminal(eLazyBoolCalculate),
m_supports_colors(eLazyBoolCalculate) {}
File(FILE *fh, bool transfer_ownership)
- : IOObject(eFDTypeFile, false), m_descriptor(kInvalidDescriptor),
- m_stream(fh), m_options(0), m_own_stream(transfer_ownership),
- m_is_interactive(eLazyBoolCalculate),
+ : IOObject(eFDTypeFile), m_descriptor(kInvalidDescriptor),
+ m_own_descriptor(false), m_stream(fh), m_options(0),
+ m_own_stream(transfer_ownership), m_is_interactive(eLazyBoolCalculate),
m_is_real_terminal(eLazyBoolCalculate),
m_supports_colors(eLazyBoolCalculate) {}
File(int fd, uint32_t options, bool transfer_ownership)
- : IOObject(eFDTypeFile, transfer_ownership), m_descriptor(fd),
- m_stream(kInvalidStream), m_options(options), m_own_stream(false),
+ : IOObject(eFDTypeFile), m_descriptor(fd),
+ m_own_descriptor(transfer_ownership), m_stream(kInvalidStream),
+ m_options(options), m_own_stream(false),
m_is_interactive(eLazyBoolCalculate),
m_is_real_terminal(eLazyBoolCalculate) {}
@@ -339,6 +340,7 @@ protected:
// Member variables
int m_descriptor;
+ bool m_own_descriptor;
FILE *m_stream;
uint32_t m_options;
bool m_own_stream;
diff --git a/lldb/include/lldb/Host/Socket.h b/lldb/include/lldb/Host/Socket.h
index 8aae97a9982..c6df5634e24 100644
--- a/lldb/include/lldb/Host/Socket.h
+++ b/lldb/include/lldb/Host/Socket.h
@@ -122,6 +122,7 @@ protected:
SocketProtocol m_protocol;
NativeSocket m_socket;
bool m_child_processes_inherit;
+ bool m_should_close_fd;
};
} // namespace lldb_private
diff --git a/lldb/include/lldb/Utility/IOObject.h b/lldb/include/lldb/Utility/IOObject.h
index 1640200a01d..16ed580abf7 100644
--- a/lldb/include/lldb/Utility/IOObject.h
+++ b/lldb/include/lldb/Utility/IOObject.h
@@ -29,8 +29,7 @@ public:
typedef int WaitableHandle;
static const WaitableHandle kInvalidHandleValue;
- IOObject(FDType type, bool should_close)
- : m_fd_type(type), m_should_close_fd(should_close) {}
+ IOObject(FDType type) : m_fd_type(type) {}
virtual ~IOObject();
virtual Status Read(void *buf, size_t &num_bytes) = 0;
@@ -44,8 +43,6 @@ public:
protected:
FDType m_fd_type;
- bool m_should_close_fd; // True if this class should close the file descriptor
- // when it goes away.
private:
DISALLOW_COPY_AND_ASSIGN(IOObject);
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(); }
OpenPOWER on IntegriCloud