diff options
author | Chris Bieneman <beanz@apple.com> | 2017-08-29 16:13:41 +0000 |
---|---|---|
committer | Chris Bieneman <beanz@apple.com> | 2017-08-29 16:13:41 +0000 |
commit | c6f6aa441b1fb0ed47b3275cd02e158a61e252ac (patch) | |
tree | 511b552dd7d5ce3e07d35c5569102359036a964d /lldb/source/Host/common/TCPSocket.cpp | |
parent | 734d8548ee93d053be45b36b612a737e6e4c61d3 (diff) | |
download | bcm5719-llvm-c6f6aa441b1fb0ed47b3275cd02e158a61e252ac.tar.gz bcm5719-llvm-c6f6aa441b1fb0ed47b3275cd02e158a61e252ac.zip |
[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.
llvm-svn: 312008
Diffstat (limited to 'lldb/source/Host/common/TCPSocket.cpp')
-rw-r--r-- | lldb/source/Host/common/TCPSocket.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lldb/source/Host/common/TCPSocket.cpp b/lldb/source/Host/common/TCPSocket.cpp index a7af93f10a7..f896944bb1b 100644 --- a/lldb/source/Host/common/TCPSocket.cpp +++ b/lldb/source/Host/common/TCPSocket.cpp @@ -198,9 +198,14 @@ Status TCPSocket::Listen(llvm::StringRef name, int backlog) { ::setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, option_value_p, sizeof(option_value)); - address.SetPort(port); - - int err = ::bind(fd, &address.sockaddr(), address.GetLength()); + SocketAddress listen_address = address; + if(!listen_address.IsLocalhost()) + listen_address.SetToAnyAddress(address.GetFamily(), port); + else + listen_address.SetPort(port); + + int err = + ::bind(fd, &listen_address.sockaddr(), listen_address.GetLength()); if (-1 != err) err = ::listen(fd, backlog); |