| Index: webrtc/p2p/base/tcpport.cc
|
| diff --git a/webrtc/p2p/base/tcpport.cc b/webrtc/p2p/base/tcpport.cc
|
| index 7dc416f923aa7e9925803d7e42e6669d4550f6fa..91b9944f0172e8c17b9ab8cea5a394880bff2304 100644
|
| --- a/webrtc/p2p/base/tcpport.cc
|
| +++ b/webrtc/p2p/base/tcpport.cc
|
| @@ -29,32 +29,32 @@
|
| * Data could only be sent in state 3. Sening data during state 2 & 6 will get
|
| * EWOULDBLOCK, 4 & 5 EPIPE.
|
| *
|
| - * 7 -------------+
|
| - * |Connected: N |
|
| - * Timeout |Writable: N | Timeout
|
| - * +------------------->|Connection is |<----------------+
|
| - * | |Dead | |
|
| - * | +--------------+ |
|
| - * | ^ |
|
| - * | OnClose | |
|
| - * | +-----------------------+ | |
|
| - * | | | |Timeout |
|
| - * | v | | |
|
| - * 4 +----------+ 5 -----+--+--+ 6 -----+-----+
|
| - * |Connected: N|Send() or |Connected: N| |Connected: Y|
|
| - * |Writable: Y|Ping() |Writable: Y|OnConnect |Writable: Y|
|
| - * |PendingTCP:N+--------> |PendingTCP:Y+---------> |PendingTCP:N|
|
| - * |PretendWri:Y| |PretendWri:Y| |PretendWri:Y|
|
| - * +-----+------+ +------------+ +---+--+-----+
|
| - * ^ ^ | |
|
| - * | | OnClose | |
|
| - * | +----------------------------------------------+ |
|
| - * | |
|
| - * | Stun Binding Completed |
|
| - * | |
|
| - * | OnClose |
|
| - * +------------------------------------------------+ |
|
| - * | v
|
| + * OS Timeout 7 -------------+
|
| + * +----------------------->|Connected: N |
|
| + * | |Writable: N | Timeout
|
| + * | Timeout |Connection is |<----------------+
|
| + * | +------------------->|Dead | |
|
| + * | | +--------------+ |
|
| + * | | ^ |
|
| + * | | OnClose | |
|
| + * | | +-----------------------+ | |
|
| + * | | | | |Timeout |
|
| + * | | v | | |
|
| + * | 4 +----------+ 5 -----+--+--+ 6 -----+-----+
|
| + * | |Connected: N|Send() or |Connected: N| |Connected: Y|
|
| + * | |Writable: Y|Ping() |Writable: Y|OnConnect |Writable: Y|
|
| + * | |PendingTCP:N+--------> |PendingTCP:Y+---------> |PendingTCP:N|
|
| + * | |PretendWri:Y| |PretendWri:Y| |PretendWri:Y|
|
| + * | +-----+------+ +------------+ +---+--+-----+
|
| + * | ^ ^ | |
|
| + * | | | OnClose | |
|
| + * | | +----------------------------------------------+ |
|
| + * | | |
|
| + * | | Stun Binding Completed |
|
| + * | | |
|
| + * | | OnClose |
|
| + * | +------------------------------------------------+ |
|
| + * | | v
|
| * 1 -----------+ 2 -----------+Stun 3 -----------+
|
| * |Connected: N| |Connected: Y|Binding |Connected: Y|
|
| * |Writable: N|OnConnect |Writable: N|Completed |Writable: Y|
|
| @@ -384,7 +384,7 @@ void TCPConnection::OnConnect(rtc::AsyncPacketSocket* socket) {
|
| << socket_ip.ToSensitiveString()
|
| << ", different from the local candidate IP "
|
| << port()->ip().ToSensitiveString();
|
| - socket_->Close();
|
| + OnClose(socket, 0);
|
| }
|
| }
|
|
|
| @@ -396,6 +396,9 @@ void TCPConnection::OnClose(rtc::AsyncPacketSocket* socket, int error) {
|
| // packet it can't send.
|
| if (connected()) {
|
| set_connected(false);
|
| +
|
| + // Prevent the connection from being destroyed by redundant SignalClose
|
| + // events.
|
| pretending_to_be_writable_ = true;
|
|
|
| // We don't attempt reconnect right here. This is to avoid a case where the
|
| @@ -403,6 +406,12 @@ void TCPConnection::OnClose(rtc::AsyncPacketSocket* socket, int error) {
|
| // when the connection is used to Send() or Ping().
|
| port()->thread()->PostDelayed(reconnection_timeout(), this,
|
| MSG_TCPCONNECTION_DELAYED_ONCLOSE);
|
| + } else if (!pretending_to_be_writable_) {
|
| + // OnClose could be called when the underneath socket times out during the
|
| + // initial connect() (i.e. |pretending_to_be_writable_| is false) . We have
|
| + // to manually destroy here as this connection, as never connected, will not
|
| + // be scheduled for ping to trigger destroy.
|
| + Destroy();
|
| }
|
| }
|
|
|
| @@ -413,7 +422,7 @@ void TCPConnection::OnMessage(rtc::Message* pmsg) {
|
| // seconds, it's time to tear this down. This is the case for the original
|
| // TCP connection on passive side during a reconnect.
|
| if (pretending_to_be_writable_) {
|
| - set_write_state(STATE_WRITE_TIMEOUT);
|
| + Destroy();
|
| }
|
| break;
|
| default:
|
|
|