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

Unified Diff: ppapi/shared_impl/tcp_socket_shared.cc

Issue 17247004: TCPSocket/UDPSocket: don't update internal state or access user buffers after Close(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/proxy/udp_socket_resource_base.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/shared_impl/tcp_socket_shared.cc
diff --git a/ppapi/shared_impl/tcp_socket_shared.cc b/ppapi/shared_impl/tcp_socket_shared.cc
index 96566373b5ed8254c6487d4e92c2445dbf7f0765..801c77187b80ea0abe590e7e1facfdc6a60bdc18 100644
--- a/ppapi/shared_impl/tcp_socket_shared.cc
+++ b/ppapi/shared_impl/tcp_socket_shared.cc
@@ -44,9 +44,13 @@ void TCPSocketShared::OnConnectCompleted(
int32_t result,
const PP_NetAddress_Private& local_addr,
const PP_NetAddress_Private& remote_addr) {
+ // It is possible that |connect_callback_| is pending while
+ // |connection_state_| is not BEFORE_CONNECT: DisconnectImpl() has been
+ // called, but a ConnectCompleted notification came earlier than the task to
+ // abort |connect_cllback_|. We don't want to udpate |connection_state_| or
dmichael (off chromium) 2013/06/22 01:19:16 nit: cllback->callback, udpate->update
yzshen1 2013/06/22 04:58:19 Done. Thanks! On 2013/06/22 01:19:16, dmichael wro
+ // other members in that case.
if (connection_state_ != BEFORE_CONNECT ||
!TrackedCallback::IsPending(connect_callback_)) {
- NOTREACHED();
return;
}
@@ -62,9 +66,13 @@ void TCPSocketShared::OnConnectCompleted(
void TCPSocketShared::OnSSLHandshakeCompleted(
bool succeeded,
const PPB_X509Certificate_Fields& certificate_fields) {
+ // It is possible that |ssl_handshake_callback_| is pending while
+ // |connection_state_| is not CONNECT: DisconnectImpl() has been
+ // called, but a SSLHandshakeCompleted notification came earlier than the task
+ // to abort |ssl_handshake_callback_|. We don't want to udpate
+ // |connection_state_| or other members in that case.
if (connection_state_ != CONNECTED ||
!TrackedCallback::IsPending(ssl_handshake_callback_)) {
- NOTREACHED();
return;
}
@@ -87,10 +95,12 @@ void TCPSocketShared::OnSSLHandshakeCompleted(
void TCPSocketShared::OnReadCompleted(int32_t result,
const std::string& data) {
- if (!TrackedCallback::IsPending(read_callback_) || !read_buffer_) {
- NOTREACHED();
+ // It is possible that |read_callback_| is pending while |read_buffer_| is
+ // NULL: DisconnectImpl() has been called, but a ReadCompleted notification
+ // came earlier than the task to abort |read_callback_|. We shouldn't access
+ // the buffer in that case. The user may have released it.
+ if (!TrackedCallback::IsPending(read_callback_) || !read_buffer_)
return;
- }
result = OverridePPError(result);
bool succeeded = result == PP_OK;
@@ -107,10 +117,8 @@ void TCPSocketShared::OnReadCompleted(int32_t result,
}
void TCPSocketShared::OnWriteCompleted(int32_t result) {
- if (!TrackedCallback::IsPending(write_callback_)) {
- NOTREACHED();
+ if (!TrackedCallback::IsPending(write_callback_))
return;
- }
result = OverridePPError(result);
write_callback_->Run(result);
« no previous file with comments | « ppapi/proxy/udp_socket_resource_base.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698