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

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

Issue 2099783002: Fixing bug where Connection drops packets when presumed writable. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Merge with master. Created 4 years, 6 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 61de2491bfcf981e8d779e67b373bd8041ec0a12..a4bde05d80cb9cac890e8aeaf81f76e3bd31611f 100644
--- a/webrtc/p2p/base/p2ptransportchannel.cc
+++ b/webrtc/p2p/base/p2ptransportchannel.cc
@@ -888,7 +888,9 @@ int P2PTransportChannel::SendPacket(const char *data, size_t len,
error_ = EINVAL;
return -1;
}
- if (selected_connection_ == NULL) {
+ // If we don't think the connection is working yet, return EWOULDBLOCK
+ // instead of sending a packet that will probably be dropped.
+ if (!ReadyToSend()) {
error_ = EWOULDBLOCK;
return -1;
}
@@ -1228,7 +1230,7 @@ void P2PTransportChannel::SwitchSelectedConnection(Connection* conn) {
LOG_J(LS_INFO, this) << "No selected connection";
}
SignalSelectedCandidatePairChanged(this, selected_connection_,
- last_sent_packet_id_);
+ last_sent_packet_id_, ReadyToSend());
}
// Warning: UpdateState should eventually be called whenever a connection
@@ -1322,6 +1324,17 @@ bool P2PTransportChannel::weak() const {
return !selected_connection_ || selected_connection_->weak();
}
+bool P2PTransportChannel::ReadyToSend() 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);
+}
+
// If we have a selected connection, return it, otherwise return top one in the
// list (later we will mark it best).
Connection* P2PTransportChannel::GetBestConnectionOnNetwork(
« 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