Skip to content

Commit dcb0e68

Browse files
committed
[lldb] [ConnectionFileDescriptorPosix] Use a single NativeFile
Replace separate read and write NativeFile instances with a single instance shared for reading and writing. There is no clear indication why two instances were used in the first place, and replacing them with just one does not seem to cause any regressions in tests or manual 'process connect file://...'. Differential Revision: https://reviews.llvm.org/D111314
1 parent 2cc7013 commit dcb0e68

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,8 @@ ConnectionFileDescriptor::ConnectionFileDescriptor(int fd, bool owns_fd)
8585
: Connection(), m_pipe(), m_mutex(), m_shutting_down(false),
8686
m_waiting_for_accept(false), m_child_processes_inherit(false) {
8787
m_write_sp =
88-
std::make_shared<NativeFile>(fd, File::eOpenOptionWriteOnly, owns_fd);
89-
m_read_sp =
90-
std::make_shared<NativeFile>(fd, File::eOpenOptionReadOnly, false);
88+
std::make_shared<NativeFile>(fd, File::eOpenOptionReadWrite, owns_fd);
89+
m_read_sp = m_write_sp;
9190

9291
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION |
9392
LIBLLDB_LOG_OBJECT));
@@ -219,9 +218,8 @@ ConnectionStatus ConnectionFileDescriptor::Connect(llvm::StringRef path,
219218
m_write_sp = m_read_sp;
220219
} else {
221220
m_read_sp = std::make_shared<NativeFile>(
222-
fd, File::eOpenOptionReadOnly, false);
223-
m_write_sp = std::make_shared<NativeFile>(
224-
fd, File::eOpenOptionWriteOnly, false);
221+
fd, File::eOpenOptionReadWrite, false);
222+
m_write_sp = m_read_sp;
225223
}
226224
m_uri = std::string(*addr);
227225
return eConnectionStatusSuccess;
@@ -271,9 +269,8 @@ ConnectionStatus ConnectionFileDescriptor::Connect(llvm::StringRef path,
271269
}
272270
}
273271
m_read_sp =
274-
std::make_shared<NativeFile>(fd, File::eOpenOptionReadOnly, true);
275-
m_write_sp =
276-
std::make_shared<NativeFile>(fd, File::eOpenOptionWriteOnly, false);
272+
std::make_shared<NativeFile>(fd, File::eOpenOptionReadWrite, true);
273+
m_write_sp = m_read_sp;
277274
return eConnectionStatusSuccess;
278275
}
279276
#endif

0 commit comments

Comments
 (0)