[Lldb-commits] [lldb] dcb0e68 - [lldb] [ConnectionFileDescriptorPosix] Use a single NativeFile

Michał Górny via lldb-commits lldb-commits at lists.llvm.org
Fri Oct 8 02:26:36 PDT 2021


Author: Michał Górny
Date: 2021-10-08T11:26:29+02:00
New Revision: dcb0e687faebb8b8c31f61a0deb8c583125ffc72

URL: https://github.com/llvm/llvm-project/commit/dcb0e687faebb8b8c31f61a0deb8c583125ffc72
DIFF: https://github.com/llvm/llvm-project/commit/dcb0e687faebb8b8c31f61a0deb8c583125ffc72.diff

LOG: [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

Added: 
    

Modified: 
    lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
index 2d93e457a6990..9a6a5aa835f55 100644
--- a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -85,9 +85,8 @@ 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 =
-      std::make_shared<NativeFile>(fd, File::eOpenOptionWriteOnly, owns_fd);
-  m_read_sp =
-      std::make_shared<NativeFile>(fd, File::eOpenOptionReadOnly, false);
+      std::make_shared<NativeFile>(fd, File::eOpenOptionReadWrite, owns_fd);
+  m_read_sp = m_write_sp;
 
   Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION |
                                                   LIBLLDB_LOG_OBJECT));
@@ -219,9 +218,8 @@ ConnectionStatus ConnectionFileDescriptor::Connect(llvm::StringRef path,
             m_write_sp = m_read_sp;
           } else {
             m_read_sp = std::make_shared<NativeFile>(
-                fd, File::eOpenOptionReadOnly, false);
-            m_write_sp = std::make_shared<NativeFile>(
-                fd, File::eOpenOptionWriteOnly, false);
+                fd, File::eOpenOptionReadWrite, false);
+            m_write_sp = m_read_sp;
           }
           m_uri = std::string(*addr);
           return eConnectionStatusSuccess;
@@ -271,9 +269,8 @@ ConnectionStatus ConnectionFileDescriptor::Connect(llvm::StringRef path,
         }
       }
       m_read_sp =
-          std::make_shared<NativeFile>(fd, File::eOpenOptionReadOnly, true);
-      m_write_sp =
-          std::make_shared<NativeFile>(fd, File::eOpenOptionWriteOnly, false);
+          std::make_shared<NativeFile>(fd, File::eOpenOptionReadWrite, true);
+      m_write_sp = m_read_sp;
       return eConnectionStatusSuccess;
     }
 #endif


        


More information about the lldb-commits mailing list