[Lldb-commits] [PATCH] Allow multiple simultaneous connections to lldb-platform

Vince Harron vince at nethacker.com
Mon Mar 30 17:30:10 PDT 2015


REPOSITORY
  rL LLVM

http://reviews.llvm.org/D8696

Files:
  lldb/trunk/include/lldb/Host/Socket.h
  lldb/trunk/source/Host/common/Socket.cpp
  lldb/trunk/tools/lldb-server/lldb-platform.cpp

Index: lldb/trunk/include/lldb/Host/Socket.h
===================================================================
--- lldb/trunk/include/lldb/Host/Socket.h
+++ lldb/trunk/include/lldb/Host/Socket.h
@@ -56,7 +56,12 @@
     // Initialize a Tcp Socket object in listening mode.  listen and accept are implemented
     // separately because the caller may wish to manipulate or query the socket after it is
     // initialized, but before entering a blocking accept.
-    static Error TcpListen(llvm::StringRef host_and_port, bool child_processes_inherit, Socket *&socket, Predicate<uint16_t>* predicate);
+    static Error TcpListen(
+        llvm::StringRef host_and_port,
+        bool child_processes_inherit,
+        Socket *&socket,
+        Predicate<uint16_t>* predicate,
+        int backlog = 5);
     static Error TcpConnect(llvm::StringRef host_and_port, bool child_processes_inherit, Socket *&socket);
     static Error UdpConnect(llvm::StringRef host_and_port, bool child_processes_inherit, Socket *&send_socket, Socket *&recv_socket);
     static Error UnixDomainConnect(llvm::StringRef host_and_port, bool child_processes_inherit, Socket *&socket);
Index: lldb/trunk/source/Host/common/Socket.cpp
===================================================================
--- lldb/trunk/source/Host/common/Socket.cpp
+++ lldb/trunk/source/Host/common/Socket.cpp
@@ -167,7 +167,12 @@
     return error;
 }
 
-Error Socket::TcpListen(llvm::StringRef host_and_port, bool child_processes_inherit, Socket *&socket, Predicate<uint16_t>* predicate)
+Error Socket::TcpListen(
+    llvm::StringRef host_and_port,
+    bool child_processes_inherit,
+    Socket *&socket,
+    Predicate<uint16_t>* predicate,
+    int backlog)
 {
     std::unique_ptr<Socket> listen_socket;
     NativeSocket listen_sock = kInvalidSocketValue;
@@ -209,7 +214,7 @@
             return error;
         }
 
-        err = ::listen (listen_sock, 1);
+        err = ::listen (listen_sock, backlog);
         if (err == -1)
         {
             // TODO: On Windows, use WSAGetLastError()
Index: lldb/trunk/tools/lldb-server/lldb-platform.cpp
===================================================================
--- lldb/trunk/tools/lldb-server/lldb-platform.cpp
+++ lldb/trunk/tools/lldb-server/lldb-platform.cpp
@@ -253,7 +253,12 @@
     Socket *socket = nullptr;
     printf ("Listening for a connection from %s...\n", listen_host_port.c_str());
     const bool children_inherit_listen_socket = false;
-    error = Socket::TcpListen(listen_host_port.c_str(), children_inherit_listen_socket, socket, NULL);
+
+    // the test suite makes many connections in parallel, let's not miss any.
+    // The highest this should get reasonably is a function of the number 
+    // of target CPUs.  For now, let's just use 100
+    const int backlog = 100;
+    error = Socket::TcpListen(listen_host_port.c_str(), children_inherit_listen_socket, socket, NULL, backlog);
     if (error.Fail())
     {
         printf("error: %s\n", error.AsCString());

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8696.22922.patch
Type: text/x-patch
Size: 3015 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150331/83ff1381/attachment.bin>


More information about the lldb-commits mailing list