Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(546)

Unified Diff: p2p/client/basicportallocator.cc

Issue 3015543002: Try creating sockets again if network change occurs after bind failed. (Closed)
Patch Set: Split up TestGatherLowCostNetworkOnly Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « p2p/base/relayport.cc ('k') | p2p/client/basicportallocator_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: p2p/client/basicportallocator.cc
diff --git a/p2p/client/basicportallocator.cc b/p2p/client/basicportallocator.cc
index e00638032734ea2b1e36ad33cb0b9d534eb4d830..f4c1fbdefa00006c513c225ed7f107b9fbad9655 100644
--- a/p2p/client/basicportallocator.cc
+++ b/p2p/client/basicportallocator.cc
@@ -1105,9 +1105,29 @@ void AllocationSequence::DisableEquivalentPhases(rtc::Network* network,
// Else turn off the stuff that we've already got covered.
- // Every config implicitly specifies local, so turn that off right away.
- *flags |= PORTALLOCATOR_DISABLE_UDP;
- *flags |= PORTALLOCATOR_DISABLE_TCP;
+ // Every config implicitly specifies local, so turn that off right away if we
+ // already have a port of the corresponding type. Look for a port that
+ // matches this AllocationSequence's network, is the right protocol, and
+ // hasn't encountered an error.
+ // TODO(deadbeef): This doesn't take into account that there may be another
+ // AllocationSequence that's ABOUT to allocate a UDP port, but hasn't yet.
+ // This can happen if, say, there's a network change event right before an
+ // application-triggered ICE restart. Hopefully this problem will just go
+ // away if we get rid of the gathering "phases" though, which is planned.
+ if (std::any_of(session_->ports_.begin(), session_->ports_.end(),
+ [this](const BasicPortAllocatorSession::PortData& p) {
+ return p.port()->Network() == network_ &&
+ p.port()->GetProtocol() == PROTO_UDP && !p.error();
+ })) {
+ *flags |= PORTALLOCATOR_DISABLE_UDP;
+ }
+ if (std::any_of(session_->ports_.begin(), session_->ports_.end(),
+ [this](const BasicPortAllocatorSession::PortData& p) {
+ return p.port()->Network() == network_ &&
+ p.port()->GetProtocol() == PROTO_TCP && !p.error();
+ })) {
+ *flags |= PORTALLOCATOR_DISABLE_TCP;
+ }
if (config_ && config) {
if (config_->StunServers() == config->StunServers()) {
« no previous file with comments | « p2p/base/relayport.cc ('k') | p2p/client/basicportallocator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698