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

Side by Side Diff: webrtc/p2p/base/tcpport.cc

Issue 2834083002: Fixing SignalSentPacket for TCP connections. (Closed)
Patch Set: Don't crash if socket wasn't created successfully. Created 3 years, 8 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 | « no previous file | webrtc/p2p/base/tcpport_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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 return NULL; 150 return NULL;
151 } 151 }
152 152
153 if (!IsCompatibleAddress(address.address())) { 153 if (!IsCompatibleAddress(address.address())) {
154 return NULL; 154 return NULL;
155 } 155 }
156 156
157 TCPConnection* conn = NULL; 157 TCPConnection* conn = NULL;
158 if (rtc::AsyncPacketSocket* socket = 158 if (rtc::AsyncPacketSocket* socket =
159 GetIncoming(address.address(), true)) { 159 GetIncoming(address.address(), true)) {
160 // Incoming connection; we already created a socket and connected signals,
161 // so we need to hand off the "read packet" responsibility to
162 // TCPConnection.
160 socket->SignalReadPacket.disconnect(this); 163 socket->SignalReadPacket.disconnect(this);
161 conn = new TCPConnection(this, address, socket); 164 conn = new TCPConnection(this, address, socket);
162 } else { 165 } else {
166 // Outgoing connection, which will create a new socket for which we still
167 // need to connect SignalReadyToSend and SignalSentPacket.
163 conn = new TCPConnection(this, address); 168 conn = new TCPConnection(this, address);
169 if (conn->socket()) {
170 conn->socket()->SignalReadyToSend.connect(this, &TCPPort::OnReadyToSend);
171 conn->socket()->SignalSentPacket.connect(this, &TCPPort::OnSentPacket);
172 }
164 } 173 }
165 AddOrReplaceConnection(conn); 174 AddOrReplaceConnection(conn);
166 return conn; 175 return conn;
167 } 176 }
168 177
169 void TCPPort::PrepareAddress() { 178 void TCPPort::PrepareAddress() {
170 if (socket_) { 179 if (socket_) {
171 // If socket isn't bound yet the address will be added in 180 // If socket isn't bound yet the address will be added in
172 // OnAddressReady(). Socket may be in the CLOSED state if Listen() 181 // OnAddressReady(). Socket may be in the CLOSED state if Listen()
173 // failed, we still want to add the socket address. 182 // failed, we still want to add the socket address.
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 void TCPConnection::ConnectSocketSignals(rtc::AsyncPacketSocket* socket) { 521 void TCPConnection::ConnectSocketSignals(rtc::AsyncPacketSocket* socket) {
513 if (outgoing_) { 522 if (outgoing_) {
514 socket->SignalConnect.connect(this, &TCPConnection::OnConnect); 523 socket->SignalConnect.connect(this, &TCPConnection::OnConnect);
515 } 524 }
516 socket->SignalReadPacket.connect(this, &TCPConnection::OnReadPacket); 525 socket->SignalReadPacket.connect(this, &TCPConnection::OnReadPacket);
517 socket->SignalReadyToSend.connect(this, &TCPConnection::OnReadyToSend); 526 socket->SignalReadyToSend.connect(this, &TCPConnection::OnReadyToSend);
518 socket->SignalClose.connect(this, &TCPConnection::OnClose); 527 socket->SignalClose.connect(this, &TCPConnection::OnClose);
519 } 528 }
520 529
521 } // namespace cricket 530 } // namespace cricket
OLDNEW
« no previous file with comments | « no previous file | webrtc/p2p/base/tcpport_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698