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

Unified Diff: net/spdy/spdy_session.cc

Issue 5216002: Merge 66630 - Fix SPDY crash on race when canceling a stream that just got cr... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/552/src/
Patch Set: Created 10 years, 1 month 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 | « net/spdy/spdy_session.h ('k') | net/spdy/spdy_session_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/spdy_session.cc
===================================================================
--- net/spdy/spdy_session.cc (revision 66644)
+++ net/spdy/spdy_session.cc (working copy)
@@ -275,6 +275,8 @@
DCHECK_EQ(0u, num_active_streams());
DCHECK_EQ(0u, num_unclaimed_pushed_streams());
+ DCHECK(pending_callback_map_.empty());
+
RecordHistograms();
net_log_.EndEvent(NetLog::TYPE_SPDY_SESSION, NULL);
@@ -362,11 +364,14 @@
pending_create.priority,
pending_create.spdy_stream,
*pending_create.stream_net_log);
+ scoped_refptr<SpdyStream>* stream = pending_create.spdy_stream;
+ DCHECK(!ContainsKey(pending_callback_map_, stream));
+ pending_callback_map_[stream] =
+ CallbackResultPair(pending_create.callback, error);
MessageLoop::current()->PostTask(
FROM_HERE,
method_factory_.NewRunnableMethod(
- &SpdySession::InvokeUserStreamCreationCallback,
- pending_create.callback, error));
+ &SpdySession::InvokeUserStreamCreationCallback, stream));
break;
}
}
@@ -377,6 +382,12 @@
void SpdySession::CancelPendingCreateStreams(
const scoped_refptr<SpdyStream>* spdy_stream) {
+ PendingCallbackMap::iterator it = pending_callback_map_.find(spdy_stream);
+ if (it != pending_callback_map_.end()) {
+ pending_callback_map_.erase(it);
+ return;
+ }
+
for (int i = 0;i < NUM_PRIORITIES;++i) {
PendingCreateStreamQueue tmp;
// Make a copy removing this trans
@@ -1303,8 +1314,17 @@
}
void SpdySession::InvokeUserStreamCreationCallback(
- CompletionCallback* callback, int rv) {
- callback->Run(rv);
+ scoped_refptr<SpdyStream>* stream) {
+ PendingCallbackMap::iterator it = pending_callback_map_.find(stream);
+
+ // Exit if the request has already been cancelled.
+ if (it == pending_callback_map_.end())
+ return;
+
+ CompletionCallback* callback = it->second.callback;
+ int result = it->second.result;
+ pending_callback_map_.erase(it);
+ callback->Run(result);
}
} // namespace net
« no previous file with comments | « net/spdy/spdy_session.h ('k') | net/spdy/spdy_session_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698