| Index: webrtc/p2p/client/basicportallocator.cc
|
| diff --git a/webrtc/p2p/client/basicportallocator.cc b/webrtc/p2p/client/basicportallocator.cc
|
| index 091819ac43f1d0e1420bcd123bb6c6384fd67291..ce95895e8ac8544996edc39fd46fe989f08a1a2b 100644
|
| --- a/webrtc/p2p/client/basicportallocator.cc
|
| +++ b/webrtc/p2p/client/basicportallocator.cc
|
| @@ -1096,7 +1096,6 @@ AllocationSequence::AllocationSequence(BasicPortAllocatorSession* session,
|
| uint32_t flags)
|
| : session_(session),
|
| network_(network),
|
| - ip_(network->GetBestIP()),
|
| config_(config),
|
| state_(kInit),
|
| flags_(flags),
|
| @@ -1108,8 +1107,8 @@ AllocationSequence::AllocationSequence(BasicPortAllocatorSession* session,
|
| void AllocationSequence::Init() {
|
| if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET)) {
|
| udp_socket_.reset(session_->socket_factory()->CreateUdpSocket(
|
| - rtc::SocketAddress(ip_, 0), session_->allocator()->min_port(),
|
| - session_->allocator()->max_port()));
|
| + rtc::SocketAddress(network_->GetBestIP(), 0),
|
| + session_->allocator()->min_port(), session_->allocator()->max_port()));
|
| if (udp_socket_) {
|
| udp_socket_->SignalReadPacket.connect(
|
| this, &AllocationSequence::OnReadPacket);
|
| @@ -1143,7 +1142,7 @@ void AllocationSequence::DisableEquivalentPhases(rtc::Network* network,
|
| return;
|
| }
|
|
|
| - if (!((network == network_) && (ip_ == network->GetBestIP()))) {
|
| + if (!((network == network_) && (previous_best_ip_ == network->GetBestIP()))) {
|
| // Different network setup; nothing is equivalent.
|
| return;
|
| }
|
| @@ -1173,6 +1172,9 @@ void AllocationSequence::DisableEquivalentPhases(rtc::Network* network,
|
| void AllocationSequence::Start() {
|
| state_ = kRunning;
|
| session_->network_thread()->Post(RTC_FROM_HERE, this, MSG_ALLOCATION_PHASE);
|
| + // Take a snapshot of the best IP, so that when DisableEquivalentPhases is
|
| + // called next time, we enable all phases if the best IP has since changed.
|
| + previous_best_ip_ = network_->GetBestIP();
|
| }
|
|
|
| void AllocationSequence::Stop() {
|
| @@ -1267,7 +1269,7 @@ void AllocationSequence::CreateUDPPorts() {
|
| session_->allocator()->origin(), emit_local_candidate_for_anyaddress);
|
| } else {
|
| port = UDPPort::Create(
|
| - session_->network_thread(), session_->socket_factory(), network_, ip_,
|
| + session_->network_thread(), session_->socket_factory(), network_,
|
| session_->allocator()->min_port(), session_->allocator()->max_port(),
|
| session_->username(), session_->password(),
|
| session_->allocator()->origin(), emit_local_candidate_for_anyaddress);
|
| @@ -1300,13 +1302,11 @@ void AllocationSequence::CreateTCPPorts() {
|
| return;
|
| }
|
|
|
| - Port* port = TCPPort::Create(session_->network_thread(),
|
| - session_->socket_factory(),
|
| - network_, ip_,
|
| - session_->allocator()->min_port(),
|
| - session_->allocator()->max_port(),
|
| - session_->username(), session_->password(),
|
| - session_->allocator()->allow_tcp_listen());
|
| + Port* port = TCPPort::Create(
|
| + session_->network_thread(), session_->socket_factory(), network_,
|
| + session_->allocator()->min_port(), session_->allocator()->max_port(),
|
| + session_->username(), session_->password(),
|
| + session_->allocator()->allow_tcp_listen());
|
| if (port) {
|
| session_->AddAllocatedPort(port, this, true);
|
| // Since TCPPort is not created using shared socket, |port| will not be
|
| @@ -1330,14 +1330,11 @@ void AllocationSequence::CreateStunPorts() {
|
| return;
|
| }
|
|
|
| - StunPort* port = StunPort::Create(session_->network_thread(),
|
| - session_->socket_factory(),
|
| - network_, ip_,
|
| - session_->allocator()->min_port(),
|
| - session_->allocator()->max_port(),
|
| - session_->username(), session_->password(),
|
| - config_->StunServers(),
|
| - session_->allocator()->origin());
|
| + StunPort* port = StunPort::Create(
|
| + session_->network_thread(), session_->socket_factory(), network_,
|
| + session_->allocator()->min_port(), session_->allocator()->max_port(),
|
| + session_->username(), session_->password(), config_->StunServers(),
|
| + session_->allocator()->origin());
|
| if (port) {
|
| session_->AddAllocatedPort(port, this, true);
|
| // Since StunPort is not created using shared socket, |port| will not be
|
| @@ -1373,12 +1370,10 @@ void AllocationSequence::CreateRelayPorts() {
|
|
|
| void AllocationSequence::CreateGturnPort(const RelayServerConfig& config) {
|
| // TODO(mallinath) - Rename RelayPort to GTurnPort.
|
| - RelayPort* port = RelayPort::Create(session_->network_thread(),
|
| - session_->socket_factory(),
|
| - network_, ip_,
|
| - session_->allocator()->min_port(),
|
| - session_->allocator()->max_port(),
|
| - config_->username, config_->password);
|
| + RelayPort* port = RelayPort::Create(
|
| + session_->network_thread(), session_->socket_factory(), network_,
|
| + session_->allocator()->min_port(), session_->allocator()->max_port(),
|
| + config_->username, config_->password);
|
| if (port) {
|
| // Since RelayPort is not created using shared socket, |port| will not be
|
| // added to the dequeue.
|
| @@ -1417,12 +1412,12 @@ void AllocationSequence::CreateTurnPort(const RelayServerConfig& config) {
|
| // Do not create a port if the server address family is known and does
|
| // not match the local IP address family.
|
| int server_ip_family = relay_port->address.ipaddr().family();
|
| - int local_ip_family = ip_.family();
|
| + int local_ip_family = network_->GetBestIP().family();
|
| if (server_ip_family != AF_UNSPEC && server_ip_family != local_ip_family) {
|
| LOG(LS_INFO) << "Server and local address families are not compatible. "
|
| << "Server address: "
|
| << relay_port->address.ipaddr().ToString()
|
| - << " Local address: " << ip_.ToString();
|
| + << " Local address: " << network_->GetBestIP().ToString();
|
| continue;
|
| }
|
|
|
| @@ -1444,15 +1439,11 @@ void AllocationSequence::CreateTurnPort(const RelayServerConfig& config) {
|
| // remove entrt from it's map.
|
| port->SignalDestroyed.connect(this, &AllocationSequence::OnPortDestroyed);
|
| } else {
|
| - port = TurnPort::Create(session_->network_thread(),
|
| - session_->socket_factory(),
|
| - network_, ip_,
|
| - session_->allocator()->min_port(),
|
| - session_->allocator()->max_port(),
|
| - session_->username(),
|
| - session_->password(),
|
| - *relay_port, config.credentials, config.priority,
|
| - session_->allocator()->origin());
|
| + port = TurnPort::Create(
|
| + session_->network_thread(), session_->socket_factory(), network_,
|
| + session_->allocator()->min_port(), session_->allocator()->max_port(),
|
| + session_->username(), session_->password(), *relay_port,
|
| + config.credentials, config.priority, session_->allocator()->origin());
|
| }
|
| RTC_DCHECK(port != NULL);
|
| port->SetTlsCertPolicy(config.tls_cert_policy);
|
|
|