| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 : PortAllocatorSession(content_name, | 177 : PortAllocatorSession(content_name, |
| 178 component, | 178 component, |
| 179 ice_ufrag, | 179 ice_ufrag, |
| 180 ice_pwd, | 180 ice_pwd, |
| 181 allocator->flags()), | 181 allocator->flags()), |
| 182 allocator_(allocator), | 182 allocator_(allocator), |
| 183 network_thread_(NULL), | 183 network_thread_(NULL), |
| 184 socket_factory_(allocator->socket_factory()), | 184 socket_factory_(allocator->socket_factory()), |
| 185 allocation_started_(false), | 185 allocation_started_(false), |
| 186 network_manager_started_(false), | 186 network_manager_started_(false), |
| 187 running_(false), | |
| 188 allocation_sequences_created_(false), | 187 allocation_sequences_created_(false), |
| 189 prune_turn_ports_(allocator->prune_turn_ports()) { | 188 prune_turn_ports_(allocator->prune_turn_ports()) { |
| 190 allocator_->network_manager()->SignalNetworksChanged.connect( | 189 allocator_->network_manager()->SignalNetworksChanged.connect( |
| 191 this, &BasicPortAllocatorSession::OnNetworksChanged); | 190 this, &BasicPortAllocatorSession::OnNetworksChanged); |
| 192 allocator_->network_manager()->StartUpdating(); | 191 allocator_->network_manager()->StartUpdating(); |
| 193 } | 192 } |
| 194 | 193 |
| 195 BasicPortAllocatorSession::~BasicPortAllocatorSession() { | 194 BasicPortAllocatorSession::~BasicPortAllocatorSession() { |
| 196 allocator_->network_manager()->StopUpdating(); | 195 allocator_->network_manager()->StopUpdating(); |
| 197 if (network_thread_ != NULL) | 196 if (network_thread_ != NULL) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 [this, &port](const Candidate& candidate) { | 231 [this, &port](const Candidate& candidate) { |
| 233 return CandidatePairable(candidate, port.port()); | 232 return CandidatePairable(candidate, port.port()); |
| 234 })) { | 233 })) { |
| 235 port.set_has_pairable_candidate(false); | 234 port.set_has_pairable_candidate(false); |
| 236 } | 235 } |
| 237 } | 236 } |
| 238 } | 237 } |
| 239 | 238 |
| 240 void BasicPortAllocatorSession::StartGettingPorts() { | 239 void BasicPortAllocatorSession::StartGettingPorts() { |
| 241 network_thread_ = rtc::Thread::Current(); | 240 network_thread_ = rtc::Thread::Current(); |
| 241 PortAllocatorSession::StartGettingPorts(); |
| 242 if (!socket_factory_) { | 242 if (!socket_factory_) { |
| 243 owned_socket_factory_.reset( | 243 owned_socket_factory_.reset( |
| 244 new rtc::BasicPacketSocketFactory(network_thread_)); | 244 new rtc::BasicPacketSocketFactory(network_thread_)); |
| 245 socket_factory_ = owned_socket_factory_.get(); | 245 socket_factory_ = owned_socket_factory_.get(); |
| 246 } | 246 } |
| 247 | 247 |
| 248 running_ = true; | |
| 249 network_thread_->Post(RTC_FROM_HERE, this, MSG_CONFIG_START); | 248 network_thread_->Post(RTC_FROM_HERE, this, MSG_CONFIG_START); |
| 250 } | 249 } |
| 251 | 250 |
| 252 void BasicPortAllocatorSession::StopGettingPorts() { | 251 void BasicPortAllocatorSession::StopGettingPorts() { |
| 253 ASSERT(rtc::Thread::Current() == network_thread_); | 252 ASSERT(rtc::Thread::Current() == network_thread_); |
| 254 running_ = false; | |
| 255 network_thread_->Post(RTC_FROM_HERE, this, MSG_CONFIG_STOP); | 253 network_thread_->Post(RTC_FROM_HERE, this, MSG_CONFIG_STOP); |
| 256 ClearGettingPorts(); | 254 ClearGettingPorts(); |
| 255 // Note: this must be called after ClearGettingPorts because both may set the |
| 256 // session state and we should set the state to STOPPED. |
| 257 PortAllocatorSession::StopGettingPorts(); |
| 257 } | 258 } |
| 258 | 259 |
| 259 void BasicPortAllocatorSession::ClearGettingPorts() { | 260 void BasicPortAllocatorSession::ClearGettingPorts() { |
| 261 ASSERT(rtc::Thread::Current() == network_thread_); |
| 260 network_thread_->Clear(this, MSG_ALLOCATE); | 262 network_thread_->Clear(this, MSG_ALLOCATE); |
| 261 for (uint32_t i = 0; i < sequences_.size(); ++i) | 263 for (uint32_t i = 0; i < sequences_.size(); ++i) { |
| 262 sequences_[i]->Stop(); | 264 sequences_[i]->Stop(); |
| 265 } |
| 266 PortAllocatorSession::ClearGettingPorts(); |
| 267 } |
| 268 |
| 269 std::vector<rtc::Network*> BasicPortAllocatorSession::GetFailedNetworks() { |
| 270 std::vector<rtc::Network*> networks = GetNetworks(); |
| 271 |
| 272 // A network interface may have both IPv4 and IPv6 networks. Only if |
| 273 // neither of the networks has any connections, the network interface |
| 274 // is considered failed and need to be regathered on. |
| 275 std::set<std::string> networks_with_connection; |
| 276 for (const PortData& data : ports_) { |
| 277 Port* port = data.port(); |
| 278 if (!port->connections().empty()) { |
| 279 networks_with_connection.insert(port->Network()->name()); |
| 280 } |
| 281 } |
| 282 |
| 283 networks.erase( |
| 284 std::remove_if(networks.begin(), networks.end(), |
| 285 [networks_with_connection](rtc::Network* network) { |
| 286 // If a network does not have any connection, it is |
| 287 // considered failed. |
| 288 return networks_with_connection.find(network->name()) != |
| 289 networks_with_connection.end(); |
| 290 }), |
| 291 networks.end()); |
| 292 return networks; |
| 293 } |
| 294 |
| 295 void BasicPortAllocatorSession::RegatherOnFailedNetworks() { |
| 296 // Find the list of networks that have no connection. |
| 297 std::vector<rtc::Network*> failed_networks = GetFailedNetworks(); |
| 298 if (failed_networks.empty()) { |
| 299 return; |
| 300 } |
| 301 |
| 302 // Mark a sequence as "network failed" if its network is in the list of failed |
| 303 // networks, so that it won't be considered as equivalent when the session |
| 304 // regathers ports and candidates. |
| 305 for (AllocationSequence* sequence : sequences_) { |
| 306 if (!sequence->network_failed() && |
| 307 std::find(failed_networks.begin(), failed_networks.end(), |
| 308 sequence->network()) != failed_networks.end()) { |
| 309 sequence->set_network_failed(); |
| 310 } |
| 311 } |
| 312 // Remove ports from being used locally and send signaling to remove |
| 313 // the candidates on the remote side. |
| 314 RemovePortsAndCandidates(failed_networks); |
| 315 |
| 316 if (allocation_started_ && network_manager_started_) { |
| 317 DoAllocate(); |
| 318 } |
| 263 } | 319 } |
| 264 | 320 |
| 265 std::vector<PortInterface*> BasicPortAllocatorSession::ReadyPorts() const { | 321 std::vector<PortInterface*> BasicPortAllocatorSession::ReadyPorts() const { |
| 266 std::vector<PortInterface*> ret; | 322 std::vector<PortInterface*> ret; |
| 267 for (const PortData& data : ports_) { | 323 for (const PortData& data : ports_) { |
| 268 if (data.ready()) { | 324 if (data.ready()) { |
| 269 ret.push_back(data.port()); | 325 ret.push_back(data.port()); |
| 270 } | 326 } |
| 271 } | 327 } |
| 272 return ret; | 328 return ret; |
| 273 } | 329 } |
| 274 | 330 |
| 275 std::vector<Candidate> BasicPortAllocatorSession::ReadyCandidates() const { | 331 std::vector<Candidate> BasicPortAllocatorSession::ReadyCandidates() const { |
| 276 std::vector<Candidate> candidates; | 332 std::vector<Candidate> candidates; |
| 277 for (const PortData& data : ports_) { | 333 for (const PortData& data : ports_) { |
| 278 if (!data.ready()) { | 334 if (!data.ready()) { |
| 279 continue; | 335 continue; |
| 280 } | 336 } |
| 281 | 337 GetCandidatesFromPort(data, &candidates); |
| 282 for (const Candidate& candidate : data.port()->Candidates()) { | |
| 283 if (!CheckCandidateFilter(candidate)) { | |
| 284 continue; | |
| 285 } | |
| 286 ProtocolType pvalue; | |
| 287 if (!StringToProto(candidate.protocol().c_str(), &pvalue) || | |
| 288 !data.sequence()->ProtocolEnabled(pvalue)) { | |
| 289 continue; | |
| 290 } | |
| 291 candidates.push_back(SanitizeRelatedAddress(candidate)); | |
| 292 } | |
| 293 } | 338 } |
| 294 return candidates; | 339 return candidates; |
| 295 } | 340 } |
| 296 | 341 |
| 342 void BasicPortAllocatorSession::GetCandidatesFromPort( |
| 343 const PortData& data, |
| 344 std::vector<Candidate>* candidates) const { |
| 345 RTC_CHECK(candidates != nullptr); |
| 346 for (const Candidate& candidate : data.port()->Candidates()) { |
| 347 if (!CheckCandidateFilter(candidate)) { |
| 348 continue; |
| 349 } |
| 350 ProtocolType pvalue; |
| 351 if (!StringToProto(candidate.protocol().c_str(), &pvalue) || |
| 352 !data.sequence()->ProtocolEnabled(pvalue)) { |
| 353 continue; |
| 354 } |
| 355 candidates->push_back(SanitizeRelatedAddress(candidate)); |
| 356 } |
| 357 } |
| 358 |
| 297 Candidate BasicPortAllocatorSession::SanitizeRelatedAddress( | 359 Candidate BasicPortAllocatorSession::SanitizeRelatedAddress( |
| 298 const Candidate& c) const { | 360 const Candidate& c) const { |
| 299 Candidate copy = c; | 361 Candidate copy = c; |
| 300 // If adapter enumeration is disabled or host candidates are disabled, | 362 // If adapter enumeration is disabled or host candidates are disabled, |
| 301 // clear the raddr of STUN candidates to avoid local address leakage. | 363 // clear the raddr of STUN candidates to avoid local address leakage. |
| 302 bool filter_stun_related_address = | 364 bool filter_stun_related_address = |
| 303 ((flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION) && | 365 ((flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION) && |
| 304 (flags() & PORTALLOCATOR_DISABLE_DEFAULT_LOCAL_CANDIDATE)) || | 366 (flags() & PORTALLOCATOR_DISABLE_DEFAULT_LOCAL_CANDIDATE)) || |
| 305 !(candidate_filter_ & CF_HOST); | 367 !(candidate_filter_ & CF_HOST); |
| 306 // If the candidate filter doesn't allow reflexive addresses, empty TURN raddr | 368 // If the candidate filter doesn't allow reflexive addresses, empty TURN raddr |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 network_thread_->Post(RTC_FROM_HERE, this, MSG_ALLOCATE); | 492 network_thread_->Post(RTC_FROM_HERE, this, MSG_ALLOCATE); |
| 431 } | 493 } |
| 432 | 494 |
| 433 void BasicPortAllocatorSession::OnAllocate() { | 495 void BasicPortAllocatorSession::OnAllocate() { |
| 434 if (network_manager_started_) | 496 if (network_manager_started_) |
| 435 DoAllocate(); | 497 DoAllocate(); |
| 436 | 498 |
| 437 allocation_started_ = true; | 499 allocation_started_ = true; |
| 438 } | 500 } |
| 439 | 501 |
| 440 void BasicPortAllocatorSession::GetNetworks( | 502 std::vector<rtc::Network*> BasicPortAllocatorSession::GetNetworks() { |
| 441 std::vector<rtc::Network*>* networks) { | 503 std::vector<rtc::Network*> networks; |
| 442 networks->clear(); | |
| 443 rtc::NetworkManager* network_manager = allocator_->network_manager(); | 504 rtc::NetworkManager* network_manager = allocator_->network_manager(); |
| 444 ASSERT(network_manager != nullptr); | 505 ASSERT(network_manager != nullptr); |
| 445 // If the network permission state is BLOCKED, we just act as if the flag has | 506 // If the network permission state is BLOCKED, we just act as if the flag has |
| 446 // been passed in. | 507 // been passed in. |
| 447 if (network_manager->enumeration_permission() == | 508 if (network_manager->enumeration_permission() == |
| 448 rtc::NetworkManager::ENUMERATION_BLOCKED) { | 509 rtc::NetworkManager::ENUMERATION_BLOCKED) { |
| 449 set_flags(flags() | PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION); | 510 set_flags(flags() | PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION); |
| 450 } | 511 } |
| 451 // If the adapter enumeration is disabled, we'll just bind to any address | 512 // If the adapter enumeration is disabled, we'll just bind to any address |
| 452 // instead of specific NIC. This is to ensure the same routing for http | 513 // instead of specific NIC. This is to ensure the same routing for http |
| 453 // traffic by OS is also used here to avoid any local or public IP leakage | 514 // traffic by OS is also used here to avoid any local or public IP leakage |
| 454 // during stun process. | 515 // during stun process. |
| 455 if (flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION) { | 516 if (flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION) { |
| 456 network_manager->GetAnyAddressNetworks(networks); | 517 network_manager->GetAnyAddressNetworks(&networks); |
| 457 } else { | 518 } else { |
| 458 network_manager->GetNetworks(networks); | 519 network_manager->GetNetworks(&networks); |
| 459 } | 520 } |
| 460 networks->erase(std::remove_if(networks->begin(), networks->end(), | 521 networks.erase(std::remove_if(networks.begin(), networks.end(), |
| 461 [this](rtc::Network* network) { | 522 [this](rtc::Network* network) { |
| 462 return allocator_->network_ignore_mask() & | 523 return allocator_->network_ignore_mask() & |
| 463 network->type(); | 524 network->type(); |
| 464 }), | 525 }), |
| 465 networks->end()); | 526 networks.end()); |
| 466 | 527 |
| 467 if (flags() & PORTALLOCATOR_DISABLE_COSTLY_NETWORKS) { | 528 if (flags() & PORTALLOCATOR_DISABLE_COSTLY_NETWORKS) { |
| 468 uint16_t lowest_cost = rtc::kNetworkCostMax; | 529 uint16_t lowest_cost = rtc::kNetworkCostMax; |
| 469 for (rtc::Network* network : *networks) { | 530 for (rtc::Network* network : networks) { |
| 470 lowest_cost = std::min<uint16_t>(lowest_cost, network->GetCost()); | 531 lowest_cost = std::min<uint16_t>(lowest_cost, network->GetCost()); |
| 471 } | 532 } |
| 472 networks->erase(std::remove_if(networks->begin(), networks->end(), | 533 networks.erase(std::remove_if(networks.begin(), networks.end(), |
| 473 [lowest_cost](rtc::Network* network) { | 534 [lowest_cost](rtc::Network* network) { |
| 474 return network->GetCost() > | 535 return network->GetCost() > |
| 475 lowest_cost + rtc::kNetworkCostLow; | 536 lowest_cost + rtc::kNetworkCostLow; |
| 476 }), | 537 }), |
| 477 networks->end()); | 538 networks.end()); |
| 478 } | 539 } |
| 540 return networks; |
| 479 } | 541 } |
| 480 | 542 |
| 481 // For each network, see if we have a sequence that covers it already. If not, | 543 // For each network, see if we have a sequence that covers it already. If not, |
| 482 // create a new sequence to create the appropriate ports. | 544 // create a new sequence to create the appropriate ports. |
| 483 void BasicPortAllocatorSession::DoAllocate() { | 545 void BasicPortAllocatorSession::DoAllocate() { |
| 484 bool done_signal_needed = false; | 546 bool done_signal_needed = false; |
| 485 std::vector<rtc::Network*> networks; | 547 std::vector<rtc::Network*> networks = GetNetworks(); |
| 486 GetNetworks(&networks); | |
| 487 | 548 |
| 488 if (networks.empty()) { | 549 if (networks.empty()) { |
| 489 LOG(LS_WARNING) << "Machine has no networks; no ports will be allocated"; | 550 LOG(LS_WARNING) << "Machine has no networks; no ports will be allocated"; |
| 490 done_signal_needed = true; | 551 done_signal_needed = true; |
| 491 } else { | 552 } else { |
| 492 PortConfiguration* config = configs_.empty() ? nullptr : configs_.back(); | 553 PortConfiguration* config = configs_.empty() ? nullptr : configs_.back(); |
| 493 for (uint32_t i = 0; i < networks.size(); ++i) { | 554 for (uint32_t i = 0; i < networks.size(); ++i) { |
| 494 uint32_t sequence_flags = flags(); | 555 uint32_t sequence_flags = flags(); |
| 495 if ((sequence_flags & DISABLE_ALL_PHASES) == DISABLE_ALL_PHASES) { | 556 if ((sequence_flags & DISABLE_ALL_PHASES) == DISABLE_ALL_PHASES) { |
| 496 // If all the ports are disabled we should just fire the allocation | 557 // If all the ports are disabled we should just fire the allocation |
| (...skipping 24 matching lines...) Expand all Loading... |
| 521 | 582 |
| 522 AllocationSequence* sequence = | 583 AllocationSequence* sequence = |
| 523 new AllocationSequence(this, networks[i], config, sequence_flags); | 584 new AllocationSequence(this, networks[i], config, sequence_flags); |
| 524 if (!sequence->Init()) { | 585 if (!sequence->Init()) { |
| 525 delete sequence; | 586 delete sequence; |
| 526 continue; | 587 continue; |
| 527 } | 588 } |
| 528 done_signal_needed = true; | 589 done_signal_needed = true; |
| 529 sequence->SignalPortAllocationComplete.connect( | 590 sequence->SignalPortAllocationComplete.connect( |
| 530 this, &BasicPortAllocatorSession::OnPortAllocationComplete); | 591 this, &BasicPortAllocatorSession::OnPortAllocationComplete); |
| 531 if (running_) | 592 if (!IsStopped()) { |
| 532 sequence->Start(); | 593 sequence->Start(); |
| 594 } |
| 533 sequences_.push_back(sequence); | 595 sequences_.push_back(sequence); |
| 534 } | 596 } |
| 535 } | 597 } |
| 536 if (done_signal_needed) { | 598 if (done_signal_needed) { |
| 537 network_thread_->Post(RTC_FROM_HERE, this, MSG_SEQUENCEOBJECTS_CREATED); | 599 network_thread_->Post(RTC_FROM_HERE, this, MSG_SEQUENCEOBJECTS_CREATED); |
| 538 } | 600 } |
| 539 } | 601 } |
| 540 | 602 |
| 541 void BasicPortAllocatorSession::OnNetworksChanged() { | 603 void BasicPortAllocatorSession::OnNetworksChanged() { |
| 542 std::vector<rtc::Network*> networks; | 604 std::vector<rtc::Network*> networks = GetNetworks(); |
| 543 GetNetworks(&networks); | 605 std::vector<rtc::Network*> failed_networks; |
| 544 for (AllocationSequence* sequence : sequences_) { | 606 for (AllocationSequence* sequence : sequences_) { |
| 545 // Remove the network from the allocation sequence if it is not in | 607 // Mark the sequence as "network failed" if its network is not in |
| 546 // |networks|. | 608 // |networks|. |
| 547 if (!sequence->network_removed() && | 609 if (!sequence->network_failed() && |
| 548 std::find(networks.begin(), networks.end(), sequence->network()) == | 610 std::find(networks.begin(), networks.end(), sequence->network()) == |
| 549 networks.end()) { | 611 networks.end()) { |
| 550 sequence->OnNetworkRemoved(); | 612 sequence->OnNetworkFailed(); |
| 613 failed_networks.push_back(sequence->network()); |
| 551 } | 614 } |
| 552 } | 615 } |
| 616 RemovePortsAndCandidates(failed_networks); |
| 553 | 617 |
| 554 network_manager_started_ = true; | 618 network_manager_started_ = true; |
| 555 if (allocation_started_) | 619 if (allocation_started_) |
| 556 DoAllocate(); | 620 DoAllocate(); |
| 557 } | 621 } |
| 558 | 622 |
| 559 void BasicPortAllocatorSession::DisableEquivalentPhases( | 623 void BasicPortAllocatorSession::DisableEquivalentPhases( |
| 560 rtc::Network* network, | 624 rtc::Network* network, |
| 561 PortConfiguration* config, | 625 PortConfiguration* config, |
| 562 uint32_t* flags) { | 626 uint32_t* flags) { |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 Port* port) { | 904 Port* port) { |
| 841 for (std::vector<PortData>::iterator it = ports_.begin(); | 905 for (std::vector<PortData>::iterator it = ports_.begin(); |
| 842 it != ports_.end(); ++it) { | 906 it != ports_.end(); ++it) { |
| 843 if (it->port() == port) { | 907 if (it->port() == port) { |
| 844 return &*it; | 908 return &*it; |
| 845 } | 909 } |
| 846 } | 910 } |
| 847 return NULL; | 911 return NULL; |
| 848 } | 912 } |
| 849 | 913 |
| 914 // Removes ports and candidates created on a given list of networks. |
| 915 void BasicPortAllocatorSession::RemovePortsAndCandidates( |
| 916 const std::vector<rtc::Network*>& networks) { |
| 917 std::vector<PortInterface*> ports_to_remove; |
| 918 std::vector<Candidate> candidates_to_remove; |
| 919 for (PortData& data : ports_) { |
| 920 if (std::find(networks.begin(), networks.end(), |
| 921 data.sequence()->network()) == networks.end()) { |
| 922 continue; |
| 923 } |
| 924 ports_to_remove.push_back(data.port()); |
| 925 if (data.has_pairable_candidate()) { |
| 926 GetCandidatesFromPort(data, &candidates_to_remove); |
| 927 // Mark the port as having no pairable candidates so that its candidates |
| 928 // won't be removed multiple times. |
| 929 data.set_has_pairable_candidate(false); |
| 930 } |
| 931 } |
| 932 if (!ports_to_remove.empty()) { |
| 933 SignalPortsRemoved(this, ports_to_remove); |
| 934 } |
| 935 if (!candidates_to_remove.empty()) { |
| 936 SignalCandidatesRemoved(this, candidates_to_remove); |
| 937 } |
| 938 } |
| 939 |
| 850 // AllocationSequence | 940 // AllocationSequence |
| 851 | 941 |
| 852 AllocationSequence::AllocationSequence(BasicPortAllocatorSession* session, | 942 AllocationSequence::AllocationSequence(BasicPortAllocatorSession* session, |
| 853 rtc::Network* network, | 943 rtc::Network* network, |
| 854 PortConfiguration* config, | 944 PortConfiguration* config, |
| 855 uint32_t flags) | 945 uint32_t flags) |
| 856 : session_(session), | 946 : session_(session), |
| 857 network_(network), | 947 network_(network), |
| 858 ip_(network->GetBestIP()), | 948 ip_(network->GetBestIP()), |
| 859 config_(config), | 949 config_(config), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 877 // are next available options to setup a communication channel. | 967 // are next available options to setup a communication channel. |
| 878 } | 968 } |
| 879 return true; | 969 return true; |
| 880 } | 970 } |
| 881 | 971 |
| 882 void AllocationSequence::Clear() { | 972 void AllocationSequence::Clear() { |
| 883 udp_port_ = NULL; | 973 udp_port_ = NULL; |
| 884 turn_ports_.clear(); | 974 turn_ports_.clear(); |
| 885 } | 975 } |
| 886 | 976 |
| 887 void AllocationSequence::OnNetworkRemoved() { | 977 void AllocationSequence::OnNetworkFailed() { |
| 888 // Stop the allocation sequence if its network is gone. | 978 RTC_DCHECK(!network_failed_); |
| 979 network_failed_ = true; |
| 980 // Stop the allocation sequence if its network failed. |
| 889 Stop(); | 981 Stop(); |
| 890 network_removed_ = true; | |
| 891 } | 982 } |
| 892 | 983 |
| 893 AllocationSequence::~AllocationSequence() { | 984 AllocationSequence::~AllocationSequence() { |
| 894 session_->network_thread()->Clear(this); | 985 session_->network_thread()->Clear(this); |
| 895 } | 986 } |
| 896 | 987 |
| 897 void AllocationSequence::DisableEquivalentPhases(rtc::Network* network, | 988 void AllocationSequence::DisableEquivalentPhases(rtc::Network* network, |
| 898 PortConfiguration* config, uint32_t* flags) { | 989 PortConfiguration* config, uint32_t* flags) { |
| 899 if (network_removed_) { | 990 if (network_failed_) { |
| 900 // If the network of this allocation sequence has ever gone away, | 991 // If the network of this allocation sequence has ever become failed, |
| 901 // it won't be equivalent to the new network. | 992 // it won't be equivalent to the new network. |
| 902 return; | 993 return; |
| 903 } | 994 } |
| 904 | 995 |
| 905 if (!((network == network_) && (ip_ == network->GetBestIP()))) { | 996 if (!((network == network_) && (ip_ == network->GetBestIP()))) { |
| 906 // Different network setup; nothing is equivalent. | 997 // Different network setup; nothing is equivalent. |
| 907 return; | 998 return; |
| 908 } | 999 } |
| 909 | 1000 |
| 910 // Else turn off the stuff that we've already got covered. | 1001 // Else turn off the stuff that we've already got covered. |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1324 ServerAddresses servers; | 1415 ServerAddresses servers; |
| 1325 for (size_t i = 0; i < relays.size(); ++i) { | 1416 for (size_t i = 0; i < relays.size(); ++i) { |
| 1326 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) { | 1417 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) { |
| 1327 servers.insert(relays[i].ports.front().address); | 1418 servers.insert(relays[i].ports.front().address); |
| 1328 } | 1419 } |
| 1329 } | 1420 } |
| 1330 return servers; | 1421 return servers; |
| 1331 } | 1422 } |
| 1332 | 1423 |
| 1333 } // namespace cricket | 1424 } // namespace cricket |
| OLD | NEW |