This revision was automatically updated to reflect the committed changes.
Closed by commit rG117512715d66: refactor: move IOObject::m_should_close_fd
into subclasses (authored by lawrence_danna).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D68152/new/
https://reviews.llvm.org/D68152
Files:
lldb/include/lldb/Host/File.h
lldb/include/lldb/Host/Socket.h
lldb/include/lldb/Utility/IOObject.h
lldb/source/Host/common/File.cpp
lldb/source/Host/common/Socket.cpp
Index: lldb/source/Host/common/Socket.cpp
===================================================================
--- lldb/source/Host/common/Socket.cpp
+++ lldb/source/Host/common/Socket.cpp
@@ -74,9 +74,10 @@
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(); }
Index: lldb/source/Host/common/File.cpp
===================================================================
--- lldb/source/Host/common/File.cpp
+++ lldb/source/Host/common/File.cpp
@@ -98,7 +98,7 @@
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 @@
#else
m_descriptor = dup(GetDescriptor());
#endif
- m_should_close_fd = true;
+ m_own_descriptor = true;
}
m_stream =
@@ -117,7 +117,7 @@
if (m_stream) {
m_own_stream = true;
- m_should_close_fd = false;
+ m_own_descriptor = false;
}
}
}
@@ -148,7 +148,7 @@
error.SetErrorToErrno();
}
- if (DescriptorIsValid() && m_should_close_fd) {
+ if (DescriptorIsValid() && m_own_descriptor) {
if (::close(m_descriptor) != 0)
error.SetErrorToErrno();
}
@@ -156,7 +156,7 @@
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;
Index: lldb/include/lldb/Utility/IOObject.h
===================================================================
--- lldb/include/lldb/Utility/IOObject.h
+++ lldb/include/lldb/Utility/IOObject.h
@@ -29,8 +29,7 @@
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 @@
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);
Index: lldb/include/lldb/Host/Socket.h
===================================================================
--- lldb/include/lldb/Host/Socket.h
+++ lldb/include/lldb/Host/Socket.h
@@ -122,6 +122,7 @@
SocketProtocol m_protocol;
NativeSocket m_socket;
bool m_child_processes_inherit;
+ bool m_should_close_fd;
};
} // namespace lldb_private
Index: lldb/include/lldb/Host/File.h
===================================================================
--- lldb/include/lldb/Host/File.h
+++ lldb/include/lldb/Host/File.h
@@ -51,22 +51,23 @@
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 @@
// Member variables
int m_descriptor;
+ bool m_own_descriptor;
FILE *m_stream;
uint32_t m_options;
bool m_own_stream;
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits