diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-24 04:27:45 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-24 04:27:45 +0000 |
commit | 284d38477d32fb20a14208d30188b9e3a2b193e4 (patch) | |
tree | c50b27027abbf65f17027e7fa8d2e420ec3bb42a /jingle | |
parent | 7dc083d0d27caf718e7ddda8e9249c4063451fb2 (diff) | |
download | chromium_src-284d38477d32fb20a14208d30188b9e3a2b193e4.zip chromium_src-284d38477d32fb20a14208d30188b9e3a2b193e4.tar.gz chromium_src-284d38477d32fb20a14208d30188b9e3a2b193e4.tar.bz2 |
Delete Session and SessionManager object synchronously.
JingleSession and JingleSessionManager were previously deleted
asychronously, but it is not necessary anymore arter we've switched to
PepperSession and PepperSessionManager. Instead changed
LibjingleTransportFactory to delete libjingle objects asynchronously.
Also fixed some bugs related that would cause crash when channel auth
fails.
BUG=115374
Review URL: http://codereview.chromium.org/9433027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123436 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'jingle')
-rw-r--r-- | jingle/glue/pseudotcp_adapter.cc | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/jingle/glue/pseudotcp_adapter.cc b/jingle/glue/pseudotcp_adapter.cc index cb6ed91..b5da932 100644 --- a/jingle/glue/pseudotcp_adapter.cc +++ b/jingle/glue/pseudotcp_adapter.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -53,6 +53,8 @@ class PseudoTcpAdapter::Core : public cricket::IPseudoTcpNotify, void SetReceiveBufferSize(int32 size); void SetSendBufferSize(int32 size); + void DeleteSocket(); + private: // These are invoked by the underlying Socket, and may trigger callbacks. // They hold a reference to |this| while running, to protect from deletion. @@ -282,6 +284,10 @@ void PseudoTcpAdapter::Core::SetSendBufferSize(int32 size) { pseudo_tcp_.SetOption(cricket::PseudoTcp::OPT_SNDBUF, size); } +void PseudoTcpAdapter::Core::DeleteSocket() { + socket_.reset(); +} + cricket::IPseudoTcpNotify::WriteResult PseudoTcpAdapter::Core::TcpWritePacket( PseudoTcp* tcp, const char* buffer, @@ -299,9 +305,14 @@ cricket::IPseudoTcpNotify::WriteResult PseudoTcpAdapter::Core::TcpWritePacket( // Our underlying socket is datagram-oriented, which means it should either // send exactly as many bytes as we requested, or fail. - int result = socket_->Write(write_buffer, len, - base::Bind(&PseudoTcpAdapter::Core::OnWritten, - base::Unretained(this))); + int result; + if (socket_.get()) { + result = socket_->Write(write_buffer, len, + base::Bind(&PseudoTcpAdapter::Core::OnWritten, + base::Unretained(this))); + } else { + result = net::ERR_CONNECTION_CLOSED; + } if (result == net::ERR_IO_PENDING) { socket_write_pending_ = true; return IPseudoTcpNotify::WR_SUCCESS; @@ -318,14 +329,13 @@ void PseudoTcpAdapter::Core::DoReadFromSocket() { if (!socket_read_buffer_) socket_read_buffer_ = new net::IOBuffer(kReadBufferSize); - while (true) { - int result = socket_->Read(socket_read_buffer_, kReadBufferSize, - base::Bind(&PseudoTcpAdapter::Core::OnRead, - base::Unretained(this))); - if (result == net::ERR_IO_PENDING) - break; - - HandleReadResults(result); + int result = 1; + while (socket_.get() && result > 0) { + result = socket_->Read(socket_read_buffer_, kReadBufferSize, + base::Bind(&PseudoTcpAdapter::Core::OnRead, + base::Unretained(this))); + if (result != net::ERR_IO_PENDING) + HandleReadResults(result); } } @@ -385,6 +395,9 @@ PseudoTcpAdapter::PseudoTcpAdapter(net::Socket* socket) PseudoTcpAdapter::~PseudoTcpAdapter() { Disconnect(); + + // Make sure that the underlying socket is destroyed before PseudoTcp. + core_->DeleteSocket(); } int PseudoTcpAdapter::Read(net::IOBuffer* buffer, int buffer_size, |