This is an archive of the discontinued LLVM Phabricator instance.

Don't use SO_REUSEADDR for *client* sockets
ClosedPublic

Authored by labath on Jun 7 2016, 11:16 AM.

Details

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.

Diff Detail

Repository
rL LLVM

Event Timeline

labath updated this revision to Diff 59916.Jun 7 2016, 11:16 AM
labath retitled this revision from to Don't use SO_REUSEADDR for *client* sockets.
labath updated this object.
labath added a reviewer: clayborg.
labath added a subscriber: lldb-commits.
clayborg accepted this revision.Jun 7 2016, 11:27 AM
clayborg edited edge metadata.

I am fine with this as long as all test suites on all systems pass.

This revision is now accepted and ready to land.Jun 7 2016, 11:27 AM
This revision was automatically updated to reflect the committed changes.