[Lldb-commits] [lldb] r272041 - Don't use SO_REUSEADDR for *client* sockets

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Tue Jun 7 11:36:38 PDT 2016


Author: labath
Date: Tue Jun  7 13:36:38 2016
New Revision: 272041

URL: http://llvm.org/viewvc/llvm-project?rev=272041&view=rev
Log:
Don't use SO_REUSEADDR for *client* sockets

Summary:
In the case of client sockets, we are not binding to a specific port, so we
should be able to just request a new one. Disregarding refactors, this code
has been here since the initial LLDB checkin, so I was unable to figure out
whether it was added as a fix for a specific problem, or just for symmetry
with server sockets, but I see no side-effect from removing it now. I was
still able to create 10000 connections within a couple of seconds, so I think
it's unlikely we will exhaust the port space (previously, I would get an
error after a couple thousand connections).

This fixes an occasional issue with connecting to the android debug bridge
deamon on OSX when running the test suite, which would occasionaly fail with
EADDRINUSE. My best guess is that this was happening because two processes
were assigned the same client port number, and then things blew up because
they were both trying to connect to the same ADB server port. I have not
observed this issue happening on Linux or Windows.

Reviewers: clayborg

Subscribers: tberghammer, danalbert, lldb-commits

Differential Revision: http://reviews.llvm.org/D21088

Modified:
    lldb/trunk/source/Host/common/TCPSocket.cpp

Modified: lldb/trunk/source/Host/common/TCPSocket.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/TCPSocket.cpp?rev=272041&r1=272040&r2=272041&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/TCPSocket.cpp (original)
+++ lldb/trunk/source/Host/common/TCPSocket.cpp Tue Jun  7 13:36:38 2016
@@ -112,9 +112,6 @@ TCPSocket::Connect(llvm::StringRef name)
     if (!DecodeHostAndPort (name, host_str, port_str, port, &error))
         return error;
 
-    // Enable local address reuse
-    SetOptionReuseAddress();
-
     struct sockaddr_in sa;
     ::memset (&sa, 0, sizeof (sa));
     sa.sin_family = kDomain;




More information about the lldb-commits mailing list