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

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

Issue 10829066: Fix a SPDY crash bug where a CHECK() is hit because a cancelled stream is considered active by the … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add SPDY/3 test. Created 8 years, 4 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
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 <map> 7 #include <map>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 DCHECK_NE(0u, stream_id); 734 DCHECK_NE(0u, stream_id);
735 // TODO(mbelshe): We should send a RST_STREAM control frame here 735 // TODO(mbelshe): We should send a RST_STREAM control frame here
736 // so that the server can cancel a large send. 736 // so that the server can cancel a large send.
737 737
738 DeleteStream(stream_id, status); 738 DeleteStream(stream_id, status);
739 } 739 }
740 740
741 void SpdySession::CloseCreatedStream(SpdyStream* stream, int status) { 741 void SpdySession::CloseCreatedStream(SpdyStream* stream, int status) {
742 DCHECK_EQ(0u, stream->stream_id()); 742 DCHECK_EQ(0u, stream->stream_id());
743 created_streams_.erase(scoped_refptr<SpdyStream>(stream)); 743 created_streams_.erase(scoped_refptr<SpdyStream>(stream));
744 } 744 }
ramant (doing other things) 2012/07/27 21:43:58 nit: consider calling DeleteCreatedStream. It is y
Ryan Hamilton 2012/07/27 21:51:35 I'll simply delete the newly created method Delete
745 745
746 void SpdySession::ResetStream(SpdyStreamId stream_id, 746 void SpdySession::ResetStream(SpdyStreamId stream_id,
747 SpdyStatusCodes status, 747 SpdyStatusCodes status,
748 const std::string& description) { 748 const std::string& description) {
749 net_log().AddEvent( 749 net_log().AddEvent(
750 NetLog::TYPE_SPDY_SESSION_SEND_RST_STREAM, 750 NetLog::TYPE_SPDY_SESSION_SEND_RST_STREAM,
751 base::Bind(&NetLogSpdyRstCallback, stream_id, status, &description)); 751 base::Bind(&NetLogSpdyRstCallback, stream_id, status, &description));
752 752
753 DCHECK(buffered_spdy_framer_.get()); 753 DCHECK(buffered_spdy_framer_.get());
754 scoped_ptr<SpdyRstStreamControlFrame> rst_frame( 754 scoped_ptr<SpdyRstStreamControlFrame> rst_frame(
755 buffered_spdy_framer_->CreateRstStream(stream_id, status)); 755 buffered_spdy_framer_->CreateRstStream(stream_id, status));
756 756
757 // Default to lowest priority unless we know otherwise. 757 // Default to lowest priority unless we know otherwise.
758 RequestPriority priority = net::IDLE; 758 RequestPriority priority = net::IDLE;
759 if(IsStreamActive(stream_id)) { 759 if(IsStreamActive(stream_id)) {
760 scoped_refptr<SpdyStream> stream = active_streams_[stream_id]; 760 scoped_refptr<SpdyStream> stream = active_streams_[stream_id];
761 priority = stream->priority(); 761 priority = stream->priority();
762 } 762 }
763 QueueFrame(rst_frame.release(), priority); 763 QueueFrame(rst_frame.release(), priority);
764 RecordProtocolErrorHistogram( 764 RecordProtocolErrorHistogram(
765 static_cast<SpdyProtocolErrorDetails>(status + STATUS_CODE_INVALID)); 765 static_cast<SpdyProtocolErrorDetails>(status + STATUS_CODE_INVALID));
766 DeleteStream(stream_id, ERR_SPDY_PROTOCOL_ERROR); 766 DeleteStream(stream_id, ERR_SPDY_PROTOCOL_ERROR);
767 } 767 }
768 768
769 void SpdySession::DeleteCreatedStream(SpdyStream* stream) {
770 created_streams_.erase(scoped_refptr<SpdyStream>(stream));
771 }
772
769 bool SpdySession::IsStreamActive(SpdyStreamId stream_id) const { 773 bool SpdySession::IsStreamActive(SpdyStreamId stream_id) const {
770 return ContainsKey(active_streams_, stream_id); 774 return ContainsKey(active_streams_, stream_id);
771 } 775 }
772 776
773 LoadState SpdySession::GetLoadState() const { 777 LoadState SpdySession::GetLoadState() const {
774 // NOTE: The application only queries the LoadState via the 778 // NOTE: The application only queries the LoadState via the
775 // SpdyNetworkTransaction, and details are only needed when 779 // SpdyNetworkTransaction, and details are only needed when
776 // we're in the process of connecting. 780 // we're in the process of connecting.
777 781
778 // If we're connecting, defer to the connection to give us the actual 782 // If we're connecting, defer to the connection to give us the actual
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1970 SSLClientSocket* SpdySession::GetSSLClientSocket() const { 1974 SSLClientSocket* SpdySession::GetSSLClientSocket() const {
1971 if (!is_secure_) 1975 if (!is_secure_)
1972 return NULL; 1976 return NULL;
1973 SSLClientSocket* ssl_socket = 1977 SSLClientSocket* ssl_socket =
1974 reinterpret_cast<SSLClientSocket*>(connection_->socket()); 1978 reinterpret_cast<SSLClientSocket*>(connection_->socket());
1975 DCHECK(ssl_socket); 1979 DCHECK(ssl_socket);
1976 return ssl_socket; 1980 return ssl_socket;
1977 } 1981 }
1978 1982
1979 } // namespace net 1983 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698