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 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
923 | 923 |
924 // Send data to the other side, using our selected connection. | 924 // Send data to the other side, using our selected connection. |
925 int P2PTransportChannel::SendPacket(const char *data, size_t len, | 925 int P2PTransportChannel::SendPacket(const char *data, size_t len, |
926 const rtc::PacketOptions& options, | 926 const rtc::PacketOptions& options, |
927 int flags) { | 927 int flags) { |
928 ASSERT(worker_thread_ == rtc::Thread::Current()); | 928 ASSERT(worker_thread_ == rtc::Thread::Current()); |
929 if (flags != 0) { | 929 if (flags != 0) { |
930 error_ = EINVAL; | 930 error_ = EINVAL; |
931 return -1; | 931 return -1; |
932 } | 932 } |
933 // If we don't think the connection is working yet, return EWOULDBLOCK | 933 // If we don't think the connection is working yet, return ENOTCONN |
934 // instead of sending a packet that will probably be dropped. | 934 // instead of sending a packet that will probably be dropped. |
935 if (!ReadyToSend()) { | 935 if (!ReadyToSend()) { |
936 error_ = EWOULDBLOCK; | 936 error_ = ENOTCONN; |
937 return -1; | 937 return -1; |
938 } | 938 } |
939 | 939 |
940 last_sent_packet_id_ = options.packet_id; | 940 last_sent_packet_id_ = options.packet_id; |
941 int sent = selected_connection_->Send(data, len, options); | 941 int sent = selected_connection_->Send(data, len, options); |
942 if (sent <= 0) { | 942 if (sent <= 0) { |
943 ASSERT(sent < 0); | 943 ASSERT(sent < 0); |
944 error_ = selected_connection_->GetError(); | 944 error_ = selected_connection_->GetError(); |
945 } | 945 } |
946 return sent; | 946 return sent; |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1287 selected_connection_ = conn; | 1287 selected_connection_ = conn; |
1288 if (selected_connection_) { | 1288 if (selected_connection_) { |
1289 if (old_selected_connection) { | 1289 if (old_selected_connection) { |
1290 LOG_J(LS_INFO, this) << "Previous selected connection: " | 1290 LOG_J(LS_INFO, this) << "Previous selected connection: " |
1291 << old_selected_connection->ToString(); | 1291 << old_selected_connection->ToString(); |
1292 } | 1292 } |
1293 LOG_J(LS_INFO, this) << "New selected connection: " | 1293 LOG_J(LS_INFO, this) << "New selected connection: " |
1294 << selected_connection_->ToString(); | 1294 << selected_connection_->ToString(); |
1295 SignalRouteChange(this, selected_connection_->remote_candidate()); | 1295 SignalRouteChange(this, selected_connection_->remote_candidate()); |
1296 // This is a temporary, but safe fix to webrtc issue 5705. | 1296 // This is a temporary, but safe fix to webrtc issue 5705. |
1297 // TODO(honghaiz): Make all EWOULDBLOCK error routed through the transport | 1297 // TODO(honghaiz): Make all ENOTCONN error routed through the transport |
1298 // channel so that it knows whether the media channel is allowed to | 1298 // channel so that it knows whether the media channel is allowed to |
1299 // send; then it will only signal ready-to-send if the media channel | 1299 // send; then it will only signal ready-to-send if the media channel |
1300 // has been disallowed to send. | 1300 // has been disallowed to send. |
1301 if (selected_connection_->writable() || | 1301 if (selected_connection_->writable() || |
1302 PresumedWritable(selected_connection_)) { | 1302 PresumedWritable(selected_connection_)) { |
1303 SignalReadyToSend(this); | 1303 SignalReadyToSend(this); |
1304 } | 1304 } |
1305 } else { | 1305 } else { |
1306 LOG_J(LS_INFO, this) << "No selected connection"; | 1306 LOG_J(LS_INFO, this) << "No selected connection"; |
1307 } | 1307 } |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1893 | 1893 |
1894 // During the initial state when nothing has been pinged yet, return the first | 1894 // During the initial state when nothing has been pinged yet, return the first |
1895 // one in the ordered |connections_|. | 1895 // one in the ordered |connections_|. |
1896 return *(std::find_if(connections_.begin(), connections_.end(), | 1896 return *(std::find_if(connections_.begin(), connections_.end(), |
1897 [conn1, conn2](Connection* conn) { | 1897 [conn1, conn2](Connection* conn) { |
1898 return conn == conn1 || conn == conn2; | 1898 return conn == conn1 || conn == conn2; |
1899 })); | 1899 })); |
1900 } | 1900 } |
1901 | 1901 |
1902 } // namespace cricket | 1902 } // namespace cricket |
OLD | NEW |