Vendor import of lldb release_50 branch r312293:

https://llvm.org/svn/llvm-project/lldb/branches/release_50@312293
This commit is contained in:
Dimitry Andric 2017-09-01 16:29:35 +00:00
parent f9cfece4e8
commit 50640c9156
2 changed files with 18 additions and 2 deletions

View File

@ -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);
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);

View File

@ -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);
}