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

Side by Side 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, 5 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 870 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 881
882 // Send data to the other side, using our selected connection. 882 // Send data to the other side, using our selected connection.
883 int P2PTransportChannel::SendPacket(const char *data, size_t len, 883 int P2PTransportChannel::SendPacket(const char *data, size_t len,
884 const rtc::PacketOptions& options, 884 const rtc::PacketOptions& options,
885 int flags) { 885 int flags) {
886 ASSERT(worker_thread_ == rtc::Thread::Current()); 886 ASSERT(worker_thread_ == rtc::Thread::Current());
887 if (flags != 0) { 887 if (flags != 0) {
888 error_ = EINVAL; 888 error_ = EINVAL;
889 return -1; 889 return -1;
890 } 890 }
891 if (selected_connection_ == NULL) { 891 // If we don't think the connection is working yet, return EWOULDBLOCK
892 // instead of sending a packet that will probably be dropped.
893 if (!ReadyToSend()) {
892 error_ = EWOULDBLOCK; 894 error_ = EWOULDBLOCK;
893 return -1; 895 return -1;
894 } 896 }
895 897
896 last_sent_packet_id_ = options.packet_id; 898 last_sent_packet_id_ = options.packet_id;
897 int sent = selected_connection_->Send(data, len, options); 899 int sent = selected_connection_->Send(data, len, options);
898 if (sent <= 0) { 900 if (sent <= 0) {
899 ASSERT(sent < 0); 901 ASSERT(sent < 0);
900 error_ = selected_connection_->GetError(); 902 error_ = selected_connection_->GetError();
901 } 903 }
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1221 // send; then it will only signal ready-to-send if the media channel 1223 // send; then it will only signal ready-to-send if the media channel
1222 // has been disallowed to send. 1224 // has been disallowed to send.
1223 if (selected_connection_->writable() || 1225 if (selected_connection_->writable() ||
1224 PresumedWritable(selected_connection_)) { 1226 PresumedWritable(selected_connection_)) {
1225 SignalReadyToSend(this); 1227 SignalReadyToSend(this);
1226 } 1228 }
1227 } else { 1229 } else {
1228 LOG_J(LS_INFO, this) << "No selected connection"; 1230 LOG_J(LS_INFO, this) << "No selected connection";
1229 } 1231 }
1230 SignalSelectedCandidatePairChanged(this, selected_connection_, 1232 SignalSelectedCandidatePairChanged(this, selected_connection_,
1231 last_sent_packet_id_); 1233 last_sent_packet_id_, ReadyToSend());
1232 } 1234 }
1233 1235
1234 // Warning: UpdateState should eventually be called whenever a connection 1236 // Warning: UpdateState should eventually be called whenever a connection
1235 // is added, deleted, or the write state of any connection changes so that the 1237 // is added, deleted, or the write state of any connection changes so that the
1236 // transport controller will get the up-to-date channel state. However it 1238 // transport controller will get the up-to-date channel state. However it
1237 // should not be called too often; in the case that multiple connection states 1239 // should not be called too often; in the case that multiple connection states
1238 // change, it should be called after all the connection states have changed. For 1240 // change, it should be called after all the connection states have changed. For
1239 // example, we call this at the end of SortConnections. 1241 // example, we call this at the end of SortConnections.
1240 void P2PTransportChannel::UpdateState() { 1242 void P2PTransportChannel::UpdateState() {
1241 TransportChannelState state = ComputeState(); 1243 TransportChannelState state = ComputeState();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1315 void P2PTransportChannel::HandleAllTimedOut() { 1317 void P2PTransportChannel::HandleAllTimedOut() {
1316 for (Connection* connection : connections_) { 1318 for (Connection* connection : connections_) {
1317 connection->Destroy(); 1319 connection->Destroy();
1318 } 1320 }
1319 } 1321 }
1320 1322
1321 bool P2PTransportChannel::weak() const { 1323 bool P2PTransportChannel::weak() const {
1322 return !selected_connection_ || selected_connection_->weak(); 1324 return !selected_connection_ || selected_connection_->weak();
1323 } 1325 }
1324 1326
1327 bool P2PTransportChannel::ReadyToSend() const {
1328 // Note that we allow sending on an unreliable connection, because it's
1329 // possible that it became unreliable simply due to bad chance.
1330 // So this shouldn't prevent attempting to send media.
1331 return selected_connection_ != nullptr &&
1332 (selected_connection_->writable() ||
1333 PresumedWritable(selected_connection_) ||
1334 selected_connection_->write_state() ==
1335 Connection::STATE_WRITE_UNRELIABLE);
1336 }
1337
1325 // If we have a selected connection, return it, otherwise return top one in the 1338 // If we have a selected connection, return it, otherwise return top one in the
1326 // list (later we will mark it best). 1339 // list (later we will mark it best).
1327 Connection* P2PTransportChannel::GetBestConnectionOnNetwork( 1340 Connection* P2PTransportChannel::GetBestConnectionOnNetwork(
1328 rtc::Network* network) const { 1341 rtc::Network* network) const {
1329 // If the selected connection is on this network, then it wins. 1342 // If the selected connection is on this network, then it wins.
1330 if (selected_connection_ && 1343 if (selected_connection_ &&
1331 (selected_connection_->port()->Network() == network)) { 1344 (selected_connection_->port()->Network() == network)) {
1332 return selected_connection_; 1345 return selected_connection_;
1333 } 1346 }
1334 1347
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
1765 1778
1766 // During the initial state when nothing has been pinged yet, return the first 1779 // During the initial state when nothing has been pinged yet, return the first
1767 // one in the ordered |connections_|. 1780 // one in the ordered |connections_|.
1768 return *(std::find_if(connections_.begin(), connections_.end(), 1781 return *(std::find_if(connections_.begin(), connections_.end(),
1769 [conn1, conn2](Connection* conn) { 1782 [conn1, conn2](Connection* conn) {
1770 return conn == conn1 || conn == conn2; 1783 return conn == conn1 || conn == conn2;
1771 })); 1784 }));
1772 } 1785 }
1773 1786
1774 } // namespace cricket 1787 } // namespace cricket
OLDNEW
« 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