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

Unified Diff: webrtc/p2p/base/p2ptransportchannel.cc

Issue 2212683002: Do not switch a connection if the new connection is not ready to send packets. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Merge Created 4 years, 4 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 | « webrtc/p2p/base/p2ptransportchannel.h ('k') | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/p2ptransportchannel.cc
diff --git a/webrtc/p2p/base/p2ptransportchannel.cc b/webrtc/p2p/base/p2ptransportchannel.cc
index cff951188820d8c6894a1c70d6fe3ac53fd0b233..ef17620b2511d69ed7577fa29a07a5ad5fda9e75 100644
--- a/webrtc/p2p/base/p2ptransportchannel.cc
+++ b/webrtc/p2p/base/p2ptransportchannel.cc
@@ -191,7 +191,7 @@ void P2PTransportChannel::AddConnection(Connection* connection) {
bool P2PTransportChannel::ShouldSwitchSelectedConnection(
Connection* new_connection,
bool* missed_receiving_unchanged_threshold) const {
- if (!new_connection || selected_connection_ == new_connection) {
+ if (!ReadyToSend(new_connection) || selected_connection_ == new_connection) {
return false;
}
@@ -940,7 +940,7 @@ int P2PTransportChannel::SendPacket(const char *data, size_t len,
}
// If we don't think the connection is working yet, return ENOTCONN
// instead of sending a packet that will probably be dropped.
- if (!ReadyToSend()) {
+ if (!ReadyToSend(selected_connection_)) {
error_ = ENOTCONN;
return -1;
}
@@ -1315,7 +1315,8 @@ void P2PTransportChannel::SwitchSelectedConnection(Connection* conn) {
LOG_J(LS_INFO, this) << "No selected connection";
}
SignalSelectedCandidatePairChanged(this, selected_connection_,
- last_sent_packet_id_, ReadyToSend());
+ last_sent_packet_id_,
+ ReadyToSend(selected_connection_));
}
// Warning: UpdateState should eventually be called whenever a connection
@@ -1409,15 +1410,14 @@ bool P2PTransportChannel::weak() const {
return !selected_connection_ || selected_connection_->weak();
}
-bool P2PTransportChannel::ReadyToSend() const {
+bool P2PTransportChannel::ReadyToSend(Connection* connection) const {
// Note that we allow sending on an unreliable connection, because it's
// possible that it became unreliable simply due to bad chance.
// So this shouldn't prevent attempting to send media.
- return selected_connection_ != nullptr &&
- (selected_connection_->writable() ||
- PresumedWritable(selected_connection_) ||
- selected_connection_->write_state() ==
- Connection::STATE_WRITE_UNRELIABLE);
+ return connection != nullptr &&
+ (connection->writable() ||
+ connection->write_state() == Connection::STATE_WRITE_UNRELIABLE ||
+ PresumedWritable(connection));
}
// If we have a selected connection, return it, otherwise return top one in the
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel.h ('k') | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698