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

Side by Side Diff: net/spdy/spdy_session.cc

Issue 295823002: Ensure races between pending and new SPDY streams don't violate session concurrency. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Switch to early return. Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « net/spdy/spdy_session.h ('k') | net/spdy/spdy_session_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 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/spdy/spdy_session.h" 5 #include "net/spdy/spdy_session.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 max_concurrent_streams_ - 819 max_concurrent_streams_ -
820 (active_streams_.size() + created_streams_.size()); 820 (active_streams_.size() + created_streams_.size());
821 } 821 }
822 for (size_t i = 0; 822 for (size_t i = 0;
823 max_requests_to_process == 0 || i < max_requests_to_process; ++i) { 823 max_requests_to_process == 0 || i < max_requests_to_process; ++i) {
824 base::WeakPtr<SpdyStreamRequest> pending_request = 824 base::WeakPtr<SpdyStreamRequest> pending_request =
825 GetNextPendingStreamRequest(); 825 GetNextPendingStreamRequest();
826 if (!pending_request) 826 if (!pending_request)
827 break; 827 break;
828 828
829 // Note that this post can race with other stream creations, and it's
830 // possible that the un-stalled stream will be stalled again if it loses.
831 // TODO(jgraettinger): Provide stronger ordering guarantees.
829 base::MessageLoop::current()->PostTask( 832 base::MessageLoop::current()->PostTask(
830 FROM_HERE, 833 FROM_HERE,
831 base::Bind(&SpdySession::CompleteStreamRequest, 834 base::Bind(&SpdySession::CompleteStreamRequest,
832 weak_factory_.GetWeakPtr(), 835 weak_factory_.GetWeakPtr(),
833 pending_request)); 836 pending_request));
834 } 837 }
835 } 838 }
836 839
837 void SpdySession::AddPooledAlias(const SpdySessionKey& alias_key) { 840 void SpdySession::AddPooledAlias(const SpdySessionKey& alias_key) {
838 pooled_aliases_.insert(alias_key); 841 pooled_aliases_.insert(alias_key);
(...skipping 2014 matching lines...) Expand 10 before | Expand all | Expand 10 after
2853 } 2856 }
2854 } 2857 }
2855 2858
2856 void SpdySession::CompleteStreamRequest( 2859 void SpdySession::CompleteStreamRequest(
2857 const base::WeakPtr<SpdyStreamRequest>& pending_request) { 2860 const base::WeakPtr<SpdyStreamRequest>& pending_request) {
2858 // Abort if the request has already been cancelled. 2861 // Abort if the request has already been cancelled.
2859 if (!pending_request) 2862 if (!pending_request)
2860 return; 2863 return;
2861 2864
2862 base::WeakPtr<SpdyStream> stream; 2865 base::WeakPtr<SpdyStream> stream;
2863 int rv = CreateStream(*pending_request, &stream); 2866 int rv = TryCreateStream(pending_request, &stream);
2864 2867
2865 if (rv == OK) { 2868 if (rv == OK) {
2866 DCHECK(stream); 2869 DCHECK(stream);
2867 pending_request->OnRequestCompleteSuccess(stream); 2870 pending_request->OnRequestCompleteSuccess(stream);
2868 } else { 2871 return;
2869 DCHECK(!stream); 2872 }
2873 DCHECK(!stream);
2874
2875 if (rv != ERR_IO_PENDING) {
2870 pending_request->OnRequestCompleteFailure(rv); 2876 pending_request->OnRequestCompleteFailure(rv);
2871 } 2877 }
2872 } 2878 }
2873 2879
2874 SSLClientSocket* SpdySession::GetSSLClientSocket() const { 2880 SSLClientSocket* SpdySession::GetSSLClientSocket() const {
2875 if (!is_secure_) 2881 if (!is_secure_)
2876 return NULL; 2882 return NULL;
2877 SSLClientSocket* ssl_socket = 2883 SSLClientSocket* ssl_socket =
2878 reinterpret_cast<SSLClientSocket*>(connection_->socket()); 2884 reinterpret_cast<SSLClientSocket*>(connection_->socket());
2879 DCHECK(ssl_socket); 2885 DCHECK(ssl_socket);
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
3069 if (!queue->empty()) { 3075 if (!queue->empty()) {
3070 SpdyStreamId stream_id = queue->front(); 3076 SpdyStreamId stream_id = queue->front();
3071 queue->pop_front(); 3077 queue->pop_front();
3072 return stream_id; 3078 return stream_id;
3073 } 3079 }
3074 } 3080 }
3075 return 0; 3081 return 0;
3076 } 3082 }
3077 3083
3078 } // namespace net 3084 } // namespace net
OLDNEW
« 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