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

Issue 3108038: Fix bug where pushed SPDY streams were never actually closed.... (Closed)

Created:
10 years, 4 months ago by Mike Belshe
Modified:
9 years, 5 months ago
CC:
chromium-reviews, cbentzel+watch_chromium.org, darin-cc_chromium.org, Paweł Hajdan Jr.
Visibility:
Public.

Description

Fix bug where pushed SPDY streams were never actually closed. The fix uncovers a few things. Previously, when we had an unclaimed push stream, we'd leave it as an "active" stream, even if the EOF had already been received on that stream. I changed it so that the push stream is removed from the active stream as soon as it is inactive, but it remains on the unclaimed_pushed_streams list. This seems more correct. The hardest part of the test was getting the test to verify the fix. To verify the fix, I modified the Push tests so that we leave the session open (e.g. terminate the list of reads with an ERR_IO_PENDING rather than an EOF so that it sits open), which gives us the opportunity to check if there are active streams left on the session when we completed the test. If so, then we'll pop an error. BUG=52898 TEST=Updated existing tests. Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=57023

Patch Set 1 #

Patch Set 2 : '' #

Patch Set 3 : '' #

Total comments: 39

Patch Set 4 : '' #

Total comments: 8

Patch Set 5 : Close unclosed sessions on helper teardown. #

Patch Set 6 : Will's comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+271 lines, -137 lines) Patch
M net/spdy/spdy_http_stream.cc View 1 chunk +2 lines, -1 line 0 comments Download
M net/spdy/spdy_network_transaction_unittest.cc View 1 2 3 4 5 21 chunks +235 lines, -117 lines 0 comments Download
M net/spdy/spdy_session.h View 1 2 3 1 chunk +7 lines, -0 lines 0 comments Download
M net/spdy/spdy_session.cc View 1 2 3 3 chunks +18 lines, -8 lines 0 comments Download
M net/spdy/spdy_stream.cc View 1 2 3 4 5 4 chunks +9 lines, -11 lines 0 comments Download

Messages

Total messages: 8 (0 generated)
Mike Belshe
10 years, 4 months ago (2010-08-22 12:59:10 UTC) #1
willchan no longer on Chromium
Everything works and LGTM as is, but I've made a number of suggestions which I ...
10 years, 4 months ago (2010-08-22 16:20:49 UTC) #2
erikchen
Hey Mike. So the reason I didn't want to remove the pushed stream from active_streams_ ...
10 years, 4 months ago (2010-08-22 17:40:05 UTC) #3
erikchen
http://codereview.chromium.org/3108038/diff/14001/15002 File net/spdy/spdy_network_transaction_unittest.cc (right): http://codereview.chromium.org/3108038/diff/14001/15002#newcode410 net/spdy/spdy_network_transaction_unittest.cc:410: scoped_refptr<SpdySession> spdy_session(pool->Get(pair, session, log)); Doesn't pool->Get create a session, ...
10 years, 4 months ago (2010-08-22 17:40:45 UTC) #4
Mike Belshe
thanks guys for the quick, weekend review! http://codereview.chromium.org/3108038/diff/14001/15002 File net/spdy/spdy_network_transaction_unittest.cc (right): http://codereview.chromium.org/3108038/diff/14001/15002#newcode337 net/spdy/spdy_network_transaction_unittest.cc:337: std::string result1(buf->data(), ...
10 years, 4 months ago (2010-08-22 21:52:29 UTC) #5
willchan no longer on Chromium
lgtm, thanks for the fix! http://codereview.chromium.org/3108038/diff/14001/15005 File net/spdy/spdy_stream.cc (right): http://codereview.chromium.org/3108038/diff/14001/15005#newcode190 net/spdy/spdy_stream.cc:190: session_->CloseStream(stream_id_, net::OK); Woops, I ...
10 years, 4 months ago (2010-08-22 23:35:38 UTC) #6
Mike Belshe
Thanks for the quick turnaround on this! http://codereview.chromium.org/3108038/diff/24001/23003 File net/spdy/spdy_network_transaction_unittest.cc (right): http://codereview.chromium.org/3108038/diff/24001/23003#newcode248 net/spdy/spdy_network_transaction_unittest.cc:248: HttpNetworkTransaction* trans() ...
10 years, 4 months ago (2010-08-23 03:23:07 UTC) #7
mbelshe
10 years, 4 months ago (2010-08-23 04:08:43 UTC) #8
Thanks for taking the time to comment, Erik.

On Sun, Aug 22, 2010 at 10:40 AM, <erikchen@chromium.org> wrote:

> Hey Mike.
> So the reason I didn't want to remove the pushed stream from
> active_streams_
> until the 0 data read gets reread is that would make OnClose get called at
> the
> right time. Under the current api, OnClose gets called only and exactly
> when the
> stream is removed from active_streams_. I guess the current tradeoff is
> between
> accuracy of the abstraction (should active_streams_ contain a pushed stream
> that
> has theoretically been told to finish by the server) and centralization of
> code.
>

OK - I'm concerned about leaving it as "active", because frames arriving for
the stream will be dealt with differently based on which state it is in.


> Your call.
> Another thought. Not for this CL, but an important fix for SPDY tests I
> never
> added. Every test that uses the spdy_session_pool should check at the end
> that
> the pool is empty. Otherwise it is possible that a spdysession will leak
> and we
> won't know about it (unless a future test calls OnIPAddressChanged, and
> gets a
> weird error)


Agree


>
>
> On 2010/08/22 16:20:49, willchan wrote:
>
>> Everything works and LGTM as is, but I've made a number of suggestions
>> which I
>> think we should probably implement, but don't necessarily have to be done
>> in
>> this changelist.
>>
>
>  http://codereview.chromium.org/3108038/diff/14001/15002
>> File net/spdy/spdy_network_transaction_unittest.cc (right):
>>
>
>  http://codereview.chromium.org/3108038/diff/14001/15002#newcode337
>> net/spdy/spdy_network_transaction_unittest.cc:337: std::string
>> result1(buf->data(), rv);
>> This result1 is unnecessary.  Just do result->append(buf->data(), rv);
>>
>
>  http://codereview.chromium.org/3108038/diff/14001/15002#newcode398
>> net/spdy/spdy_network_transaction_unittest.cc:398: {
>> Nit: Is there a reason you need to scope this?  Is it to make it clear
>> what
>>
> the
>
>> code is doing?  It'd probably be better to write a GetSpdySessionForURL()
>> function or something, rather than writing a lengthy comment.  That's just
>> how
>>
> I
>
>> would do it, but feel free to do it this way if you prefer.
>>
>
>  http://codereview.chromium.org/3108038/diff/14001/15002#newcode400
>> net/spdy/spdy_network_transaction_unittest.cc:400: // session.  Once we
>> have
>>
> the
>
>> sesion, we verify that the streams are
>> session
>>
>
>  http://codereview.chromium.org/3108038/diff/14001/15002#newcode402
>> net/spdy/spdy_network_transaction_unittest.cc:402: GURL url =
>> helper.request().url;
>> const GURL&
>>
>
>  http://codereview.chromium.org/3108038/diff/14001/15002#newcode2178
>> net/spdy/spdy_network_transaction_unittest.cc:2178: 'p', 'u', 's', 'h',
>> 'e',
>>
> 'd'
>
>>                                 // "hello"
>> update comment
>>
>
>  http://codereview.chromium.org/3108038/diff/14001/15002#newcode2186
>> net/spdy/spdy_network_transaction_unittest.cc:2186:
>>
> scoped_ptr<spdy::SpdyFrame>
>
>> resp(ConstructSpdyGetSynReply(NULL, 0, 1));
>> Meta-comment: these variable names suck.  resp and rep?  It's confusing.
>>  I
>> think of resp == response and rep == reply.  But It's not obvious what the
>> responses/replies are to.  Nothing you have to fix in this changelist, but
>> I
>> thought I'd mention it.
>>
>
>  http://codereview.chromium.org/3108038/diff/14001/15002#newcode2191
>> net/spdy/spdy_network_transaction_unittest.cc:2191:
>>
> CreateMockRead(*body.get(),
>
>> 4, false),
>> Is this a bugfix?  Is it because we don't have a FIN on resp?
>>
>
>  http://codereview.chromium.org/3108038/diff/14001/15002#newcode2216
>> net/spdy/spdy_network_transaction_unittest.cc:2216: 'p', 'u', 's', 'h',
>> 'e',
>>
> 'd'
>
>>                                 // "hello"
>> update comment
>>
>
>  http://codereview.chromium.org/3108038/diff/14001/15002#newcode2264
>> net/spdy/spdy_network_transaction_unittest.cc:2264: 'p', 'u', 's', 'h',
>> 'e',
>>
> 'd'
>
>>                                 // "hello"
>> update comment
>>
>
>  http://codereview.chromium.org/3108038/diff/14001/15003
>> File net/spdy/spdy_session.cc (right):
>>
>
>  http://codereview.chromium.org/3108038/diff/14001/15003#newcode201
>> net/spdy/spdy_session.cc:201: RecordHistograms();
>> I think that at the end of SpdySession(), we should DCHECK all the stream
>>
> lists
>
>> to make sure they're empty.  CloseAllStreams() should have cleared them
>> all
>>
> out
>
>> by this point.
>>
>
>  http://codereview.chromium.org/3108038/diff/14001/15003#newcode781
>> net/spdy/spdy_session.cc:781: if (!unclaimed_pushed_streams_.empty()) {
>> Should we also do unclaimed_pushed_streams_.clear(); here?  Otherwise,
>> we're
>>
> not
>
>> closing all streams.
>>
>
>  http://codereview.chromium.org/3108038/diff/14001/15004
>> File net/spdy/spdy_session.h (right):
>>
>
>  http://codereview.chromium.org/3108038/diff/14001/15004#newcode167
>> net/spdy/spdy_session.h:167: size_t num_active_streams() { return
>> active_streams_.size(); }
>> These new accessors should be const.
>>
>
>  http://codereview.chromium.org/3108038/diff/14001/15005
>> File net/spdy/spdy_stream.cc (right):
>>
>
>  http://codereview.chromium.org/3108038/diff/14001/15005#newcode189
>> net/spdy/spdy_stream.cc:189: scoped_refptr<SpdyStream> self(this);
>> Can we avoid this self-reference?  It looks like you do it because
>>
> CloseStream()
>
>> could remove the last reference and delete the object, which would cause
>>
> badness
>
>> in UpdateHistograms().  Can we move UpdateHistograms into the destructor?
>>  Or
>> does that cause problems since we might be updating the histograms too
>> late?
>> It'd also remove the need to have the boolean that checks to make sure we
>>
> don't
>
>> update the histograms more than once per stream.
>>
>
>  http://codereview.chromium.org/3108038/diff/14001/15005#newcode190
>> net/spdy/spdy_stream.cc:190: session_->CloseStream(stream_id_, net::OK);
>> Now that we're closing the stream here, which removes it from the active
>> streams, a subsequent CloseAllStreams() won't call OnClose() on this
>> stream,
>> since it's only in the unclaimed push streams list.  Perhaps you need have
>> DeleteStream() or CloseAllStreams() do this.  Not calling OnClose() is
>>
> currently
>
>> benign, but seems "wrong", since you'd expect that CloseAllStreams() would
>>
> call
>
>> OnClose() on all streams.  I'm afraid that it's possible for a future
>> refactor
>> to introduce a bug here.
>>
>
>
>
> http://codereview.chromium.org/3108038/show
>

Powered by Google App Engine
This is Rietveld 408576698