diff --git a/p2p/base/port_unittest.cc b/p2p/base/port_unittest.cc index 9c4bc0f075..48607d1355 100644 --- a/p2p/base/port_unittest.cc +++ b/p2p/base/port_unittest.cc @@ -1503,22 +1503,6 @@ TEST_F(PortTest, TestDelayedBindingUdp) { EXPECT_EQ(1U, port->Candidates().size()); } -TEST_F(PortTest, TestDelayedBindingTcp) { - FakeAsyncPacketSocket* socket = new FakeAsyncPacketSocket(); - FakePacketSocketFactory socket_factory; - - socket_factory.set_next_server_tcp_socket(socket); - auto port = CreateTcpPort(kLocalAddr1, &socket_factory); - - socket->set_state(AsyncPacketSocket::STATE_BINDING); - port->PrepareAddress(); - - EXPECT_EQ(0U, port->Candidates().size()); - socket->SignalAddressReady(socket, kLocalAddr2); - - EXPECT_EQ(1U, port->Candidates().size()); -} - TEST_F(PortTest, TestDisableInterfaceOfTcpPort) { FakeAsyncPacketSocket* lsocket = new FakeAsyncPacketSocket(); FakeAsyncPacketSocket* rsocket = new FakeAsyncPacketSocket(); @@ -1530,10 +1514,10 @@ TEST_F(PortTest, TestDisableInterfaceOfTcpPort) { socket_factory.set_next_server_tcp_socket(rsocket); auto rport = CreateTcpPort(kLocalAddr2, &socket_factory); - lsocket->set_state(AsyncPacketSocket::STATE_BINDING); - lsocket->SignalAddressReady(lsocket, kLocalAddr1); - rsocket->set_state(AsyncPacketSocket::STATE_BINDING); - rsocket->SignalAddressReady(rsocket, kLocalAddr2); + lsocket->set_state(AsyncPacketSocket::STATE_BOUND); + lsocket->local_address_ = kLocalAddr1; + rsocket->set_state(AsyncPacketSocket::STATE_BOUND); + rsocket->local_address_ = kLocalAddr2; lport->SetIceRole(cricket::ICEROLE_CONTROLLING); lport->SetIceTiebreaker(kTiebreaker1); @@ -1576,12 +1560,14 @@ void PortTest::TestCrossFamilyPorts(int type) { if (type == SOCK_DGRAM) { factory.set_next_udp_socket(socket); ports[i] = CreateUdpPort(addresses[i], &factory); + socket->set_state(AsyncPacketSocket::STATE_BINDING); + socket->SignalAddressReady(socket, addresses[i]); } else if (type == SOCK_STREAM) { factory.set_next_server_tcp_socket(socket); ports[i] = CreateTcpPort(addresses[i], &factory); + socket->set_state(AsyncPacketSocket::STATE_BOUND); + socket->local_address_ = addresses[i]; } - socket->set_state(AsyncPacketSocket::STATE_BINDING); - socket->SignalAddressReady(socket, addresses[i]); ports[i]->PrepareAddress(); } diff --git a/p2p/base/tcp_port.cc b/p2p/base/tcp_port.cc index 4c5c38e8fe..d6b8e3ace6 100644 --- a/p2p/base/tcp_port.cc +++ b/p2p/base/tcp_port.cc @@ -166,8 +166,7 @@ Connection* TCPPort::CreateConnection(const Candidate& address, void TCPPort::PrepareAddress() { if (socket_) { - // If socket isn't bound yet the address will be added in - // OnAddressReady(). Socket may be in the CLOSED state if Listen() + // Socket may be in the CLOSED state if Listen() // failed, we still want to add the socket address. RTC_LOG(LS_VERBOSE) << "Preparing TCP address, current state: " << socket_->GetState(); @@ -300,7 +299,6 @@ void TCPPort::TryCreateServerSocket() { return; } socket_->SignalNewConnection.connect(this, &TCPPort::OnNewConnection); - socket_->SignalAddressReady.connect(this, &TCPPort::OnAddressReady); } rtc::AsyncPacketSocket* TCPPort::GetIncoming(const rtc::SocketAddress& addr, @@ -335,13 +333,6 @@ void TCPPort::OnReadyToSend(rtc::AsyncPacketSocket* socket) { Port::OnReadyToSend(); } -void TCPPort::OnAddressReady(rtc::AsyncPacketSocket* socket, - const rtc::SocketAddress& address) { - AddAddress(address, address, rtc::SocketAddress(), TCP_PROTOCOL_NAME, "", - TCPTYPE_PASSIVE_STR, LOCAL_PORT_TYPE, ICE_TYPE_PREFERENCE_HOST_TCP, - 0, "", true); -} - // TODO(qingsi): `CONNECTION_WRITE_CONNECT_TIMEOUT` is overriden by // `ice_unwritable_timeout` in IceConfig when determining the writability state. // Replace this constant with the config parameter assuming the default value if diff --git a/p2p/base/tcp_port.h b/p2p/base/tcp_port.h index 36257b07ed..6e7d00feb2 100644 --- a/p2p/base/tcp_port.h +++ b/p2p/base/tcp_port.h @@ -102,9 +102,6 @@ class TCPPort : public Port { void OnReadyToSend(rtc::AsyncPacketSocket* socket); - void OnAddressReady(rtc::AsyncPacketSocket* socket, - const rtc::SocketAddress& address); - bool allow_listen_; rtc::AsyncPacketSocket* socket_; int error_; diff --git a/rtc_base/async_packet_socket.h b/rtc_base/async_packet_socket.h index d47d57b692..89797aad34 100644 --- a/rtc_base/async_packet_socket.h +++ b/rtc_base/async_packet_socket.h @@ -117,8 +117,7 @@ class RTC_EXPORT AsyncPacketSocket : public sigslot::has_slots<> { // Emitted after address for the socket is allocated, i.e. binding // is finished. State of the socket is changed from BINDING to BOUND - // (for UDP and server TCP sockets) or CONNECTING (for client TCP - // sockets). + // (for UDP sockets). sigslot::signal2 SignalAddressReady; // Emitted for client TCP sockets when state is changed from