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

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

Issue 18796003: When an idle socket is added back to a socket pool, check for stalled jobs in lower pools (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: sync Created 7 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 <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 510
511 net_log_.AddEvent( 511 net_log_.AddEvent(
512 NetLog::TYPE_SPDY_SESSION_INITIALIZED, 512 NetLog::TYPE_SPDY_SESSION_INITIALIZED,
513 connection_->socket()->NetLog().source().ToEventParametersCallback()); 513 connection_->socket()->NetLog().source().ToEventParametersCallback());
514 514
515 int error = DoReadLoop(READ_STATE_DO_READ, OK); 515 int error = DoReadLoop(READ_STATE_DO_READ, OK);
516 if (error == ERR_IO_PENDING) 516 if (error == ERR_IO_PENDING)
517 error = OK; 517 error = OK;
518 if (error == OK) { 518 if (error == OK) {
519 DCHECK_NE(availability_state_, STATE_CLOSED); 519 DCHECK_NE(availability_state_, STATE_CLOSED);
520 connection_->AddLayeredPool(this); 520 connection_->AddHigherLayeredPool(this);
521 if (enable_sending_initial_data_) 521 if (enable_sending_initial_data_)
522 SendInitialData(); 522 SendInitialData();
523 pool_ = pool; 523 pool_ = pool;
524 } else { 524 } else {
525 DcheckClosed(); 525 DcheckClosed();
526 } 526 }
527 return static_cast<Error>(error); 527 return static_cast<Error>(error);
528 } 528 }
529 529
530 bool SpdySession::VerifyDomainAuthentication(const std::string& domain) { 530 bool SpdySession::VerifyDomainAuthentication(const std::string& domain) {
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 active_streams_.erase(it); 1041 active_streams_.erase(it);
1042 1042
1043 // TODO(akalin): When SpdyStream was ref-counted (and 1043 // TODO(akalin): When SpdyStream was ref-counted (and
1044 // |unclaimed_pushed_streams_| held scoped_refptr<SpdyStream>), this 1044 // |unclaimed_pushed_streams_| held scoped_refptr<SpdyStream>), this
1045 // was only done when status was not OK. This meant that pushed 1045 // was only done when status was not OK. This meant that pushed
1046 // streams can still be claimed after they're closed. This is 1046 // streams can still be claimed after they're closed. This is
1047 // probably something that we still want to support, although server 1047 // probably something that we still want to support, although server
1048 // push is hardly used. Write tests for this and fix this. (See 1048 // push is hardly used. Write tests for this and fix this. (See
1049 // http://crbug.com/261712 .) 1049 // http://crbug.com/261712 .)
1050 if (owned_stream->type() == SPDY_PUSH_STREAM) 1050 if (owned_stream->type() == SPDY_PUSH_STREAM)
1051 unclaimed_pushed_streams_.erase(owned_stream->url()); 1051 unclaimed_pushed_streams_.erase(owned_stream->url());
akalin 2013/08/21 17:29:03 can you fix this indent while you're here?
mmenke 2013/08/21 18:17:16 Done.
1052 1052
1053 // If there are no active streams, and the socket pool is stalled, try to free
1054 // up a socket slot. This must be done before the call to DeleteStream, as it
1055 // may delete the session.
1056 if (active_streams_.empty() && availability_state_ == STATE_AVAILABLE &&
akalin 2013/08/21 17:29:03 i think this should go after DeleteStream, as othe
mmenke 2013/08/21 18:17:16 Done.
1057 connection_->IsPoolStalled()) {
1058 // Can't close the session synchronously, because callers don't expect it.
1059 base::MessageLoop::current()->PostTask(
akalin 2013/08/21 17:29:03 you should be able to just call CloseIfIdle here d
mmenke 2013/08/21 18:17:16 Done. When I wrote this CL a month ago, that resu
1060 FROM_HERE, base::Bind(&SpdySession::CloseIfIdle,
1061 weak_factory_.GetWeakPtr()));
1062 }
1063
1053 DeleteStream(owned_stream.Pass(), status); 1064 DeleteStream(owned_stream.Pass(), status);
1065
1066 // |this| may have been deleted at this point.
1054 } 1067 }
1055 1068
1056 void SpdySession::CloseCreatedStreamIterator(CreatedStreamSet::iterator it, 1069 void SpdySession::CloseCreatedStreamIterator(CreatedStreamSet::iterator it,
1057 int status) { 1070 int status) {
1058 scoped_ptr<SpdyStream> owned_stream(*it); 1071 scoped_ptr<SpdyStream> owned_stream(*it);
1059 created_streams_.erase(it); 1072 created_streams_.erase(it);
1060 DeleteStream(owned_stream.Pass(), status); 1073 DeleteStream(owned_stream.Pass(), status);
1061 } 1074 }
1062 1075
1063 void SpdySession::ResetStreamIterator(ActiveStreamMap::iterator it, 1076 void SpdySession::ResetStreamIterator(ActiveStreamMap::iterator it,
(...skipping 1854 matching lines...) Expand 10 before | Expand all | Expand 10 after
2918 std::deque<SpdyStreamId>* queue = &stream_send_unstall_queue_[i]; 2931 std::deque<SpdyStreamId>* queue = &stream_send_unstall_queue_[i];
2919 if (!queue->empty()) { 2932 if (!queue->empty()) {
2920 SpdyStreamId stream_id = queue->front(); 2933 SpdyStreamId stream_id = queue->front();
2921 queue->pop_front(); 2934 queue->pop_front();
2922 return stream_id; 2935 return stream_id;
2923 } 2936 }
2924 } 2937 }
2925 return 0; 2938 return 0;
2926 } 2939 }
2927 2940
2941 void SpdySession::CloseIfIdle() {
2942 // If the session isn't idle, or it has already been closed, do nothing.
2943 if (!active_streams_.empty() || availability_state_ == STATE_CLOSED || !pool_)
2944 return;
2945 DoCloseSession(ERR_CONNECTION_CLOSED, "Closing idle connection.");
2946 }
2947
2928 } // namespace net 2948 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698