[llvm-branch-commits] [lldb] r312016 - Merging r312008:

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Aug 29 10:33:28 PDT 2017


Author: hans
Date: Tue Aug 29 10:33:27 2017
New Revision: 312016

URL: http://llvm.org/viewvc/llvm-project?rev=312016&view=rev
Log:
Merging r312008:
------------------------------------------------------------------------
r312008 | cbieneman | 2017-08-29 09:13:41 -0700 (Tue, 29 Aug 2017) | 7 lines

[IPv6] Fix a bug in the IPv6 listen behavior

The socket bind address should either be localhost or anyaddress. This bug in the listen behavior was preventing lldb-server from opening sockets for non-localhost connections.

The added test verifies that opening an anyaddress socket works and has a non-zero port assignment.

This should resolve PR34183.
------------------------------------------------------------------------

Modified:
    lldb/branches/release_50/   (props changed)
    lldb/branches/release_50/source/Host/common/TCPSocket.cpp
    lldb/branches/release_50/unittests/Host/SocketTest.cpp

Propchange: lldb/branches/release_50/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Aug 29 10:33:27 2017
@@ -1,3 +1,3 @@
 /lldb/branches/apple/python-GIL:156467-162159
 /lldb/branches/iohandler:198360-200250
-/lldb/trunk:311122,311354-311355,311579
+/lldb/trunk:311122,311354-311355,311579,312008

Modified: lldb/branches/release_50/source/Host/common/TCPSocket.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/release_50/source/Host/common/TCPSocket.cpp?rev=312016&r1=312015&r2=312016&view=diff
==============================================================================
--- lldb/branches/release_50/source/Host/common/TCPSocket.cpp (original)
+++ lldb/branches/release_50/source/Host/common/TCPSocket.cpp Tue Aug 29 10:33:27 2017
@@ -198,9 +198,14 @@ Status TCPSocket::Listen(llvm::StringRef
     ::setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, option_value_p,
                  sizeof(option_value));
 
-    address.SetPort(port);
+    SocketAddress listen_address = address;
+    if(!listen_address.IsLocalhost())
+      listen_address.SetToAnyAddress(address.GetFamily(), port);
+    else
+      listen_address.SetPort(port);
 
-    int err = ::bind(fd, &address.sockaddr(), address.GetLength());
+    int err =
+        ::bind(fd, &listen_address.sockaddr(), listen_address.GetLength());
     if (-1 != err)
       err = ::listen(fd, backlog);
 

Modified: lldb/branches/release_50/unittests/Host/SocketTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/release_50/unittests/Host/SocketTest.cpp?rev=312016&r1=312015&r2=312016&view=diff
==============================================================================
--- lldb/branches/release_50/unittests/Host/SocketTest.cpp (original)
+++ lldb/branches/release_50/unittests/Host/SocketTest.cpp Tue Aug 29 10:33:27 2017
@@ -220,3 +220,14 @@ TEST_F(SocketTest, UDPConnect) {
   EXPECT_TRUE(error.Success());
   EXPECT_TRUE(socket_up->IsValid());
 }
+
+TEST_F(SocketTest, TCPListen0GetPort) {
+  Socket *server_socket;
+  Predicate<uint16_t> port_predicate;
+  port_predicate.SetValue(0, eBroadcastNever);
+  Status err =
+      Socket::TcpListen("10.10.12.3:0", false, server_socket, &port_predicate);
+  std::unique_ptr<TCPSocket> socket_up((TCPSocket*)server_socket);
+  EXPECT_TRUE(socket_up->IsValid());
+  EXPECT_NE(socket_up->GetLocalPortNumber(), 0);
+}




More information about the llvm-branch-commits mailing list