Re: INVALID_STREAM and STREAM_ALREADY_CLOSED

William Chan (陈智昌) <willchan@chromium.org> Tue, 26 March 2013 21:10 UTC

Return-Path: <ietf-http-wg-request@listhub.w3.org>
X-Original-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Delivered-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 9AA3421F86C3 for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Tue, 26 Mar 2013 14:10:06 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -9.676
X-Spam-Level:
X-Spam-Status: No, score=-9.676 tagged_above=-999 required=5 tests=[BAYES_00=-2.599, FM_FORGED_GMAIL=0.622, HTML_MESSAGE=0.001, MIME_8BIT_HEADER=0.3, RCVD_IN_DNSWL_HI=-8]
Received: from mail.ietf.org ([12.22.58.30]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3HNZBNQ7bf8d for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Tue, 26 Mar 2013 14:10:05 -0700 (PDT)
Received: from frink.w3.org (frink.w3.org [128.30.52.56]) by ietfa.amsl.com (Postfix) with ESMTP id 52F8E21F86B9 for <httpbisa-archive-bis2Juki@lists.ietf.org>; Tue, 26 Mar 2013 14:10:05 -0700 (PDT)
Received: from lists by frink.w3.org with local (Exim 4.72) (envelope-from <ietf-http-wg-request@listhub.w3.org>) id 1UKb7L-0007wN-GR for ietf-http-wg-dist@listhub.w3.org; Tue, 26 Mar 2013 21:09:15 +0000
Resent-Date: Tue, 26 Mar 2013 21:09:15 +0000
Resent-Message-Id: <E1UKb7L-0007wN-GR@frink.w3.org>
Received: from lisa.w3.org ([128.30.52.41]) by frink.w3.org with esmtp (Exim 4.72) (envelope-from <willchan@google.com>) id 1UKb78-0007uQ-Ox for ietf-http-wg@listhub.w3.org; Tue, 26 Mar 2013 21:09:02 +0000
Received: from mail-qe0-f52.google.com ([209.85.128.52]) by lisa.w3.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.72) (envelope-from <willchan@google.com>) id 1UKb77-0005cP-Lj for ietf-http-wg@w3.org; Tue, 26 Mar 2013 21:09:02 +0000
Received: by mail-qe0-f52.google.com with SMTP id jy17so2433027qeb.25 for <ietf-http-wg@w3.org>; Tue, 26 Mar 2013 14:08:35 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=9Q1HNL37KWXvYsPvUqiD1PRW401ZSyhSJVt+tAi2Qac=; b=UA5fSYiXWF7cR71odZc64bsAPnalmL3aQWGFjO3KpeMrlWu/oL8bjUHaLxzxGlpBJ2 UZDKQJzoNmyekDeOGPy1zDqyt1tKLloCy3d8Wdb//+ZlOOGaUmFc3p1gA6VdVNYnGbhB 8w13R1H1CPmScQg24wSTOwUZMPKf5mCU8GNJfwDGZKbuFH5Q4MEhaOKdA7oGA2svfwms hvuKSNPHVJS/yrjVG3sNwpaPZnyawhYdRjCTw9mT97QswrBMzpl4ponMggUIMplJ4LNG WzWuYYqGqI7USHodN56gziYgl+ERBdrITK/gbFBGi1LfYbFzvGjh2ikMVHm5Xb4x7zLL hd9g==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:x-received:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=9Q1HNL37KWXvYsPvUqiD1PRW401ZSyhSJVt+tAi2Qac=; b=j9rHnm9WkGicz/QrUZjyvhqEA00bz8nPVQBo7cWrTeJGvNlpYL909r2dpXRz9V7/Bs AhRk3NKxKoGgw8OPP2QojPLKtx4omwQKOYCLlQ4dgYYuNLxmmQxsiGUhOJP6Yy+5TBFy tOCS9frA85KIpmkjc+UEY5xvYMDqGdcMIqvLE=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :x-gm-message-state; bh=9Q1HNL37KWXvYsPvUqiD1PRW401ZSyhSJVt+tAi2Qac=; b=kef8iUVlD5WO+RRBYTbusHY4UkRZuxmRbDZpiYxQaexd733K3qpXGUl+4JO/JiYneG OqO6tS1CVwomw7OSYdp9r5najLKmGTgOzbzzdjHN0tt5zoit1SEhBtUFKsE/7JW7vQEZ CQ5IOYvUb8gYoF7K4TdqhytIeRyUJQi42OzhreupKCAOwIp2AaCH52gW3ayxgbbLTFgJ XXcaedlUNgVlFcl6unrH68kgqGjZsvt2RO90+DO8t3Wa/7MMCMRQl4pC2e3+9R3grPlj FbDwo7DSua0O8Eo1f0RRDcw1e9fEi8JzPo1jGuJc/gcs1cTSc9TmHnnW7Q2+Si8UmBFP j3OA==
MIME-Version: 1.0
X-Received: by 10.49.62.2 with SMTP id u2mr10666508qer.22.1364332115750; Tue, 26 Mar 2013 14:08:35 -0700 (PDT)
Sender: willchan@google.com
Received: by 10.229.180.4 with HTTP; Tue, 26 Mar 2013 14:08:35 -0700 (PDT)
In-Reply-To: <CABkgnnWh5=Cf_WvNyRStYb8ogW3S8tHBQf7VVAMuMPRXxwM7VA@mail.gmail.com>
References: <CABkgnnX+26FBCk0VFTEC4sPBrt4DMqWSSdFcvFRVPVYLiCOLng@mail.gmail.com> <CAP+FsNcy1KA0qs=knJzfyfcwjUbWAsWGB9zL5PjAFbrp+V5OwA@mail.gmail.com> <CAA4WUYj2T3QAC9wimrOHfU1V3C3hL2sXt4W81xGk8DZCGCnWpQ@mail.gmail.com> <CABkgnnWh5=Cf_WvNyRStYb8ogW3S8tHBQf7VVAMuMPRXxwM7VA@mail.gmail.com>
Date: Tue, 26 Mar 2013 14:08:35 -0700
X-Google-Sender-Auth: KmrAhJ2IVFgqsHVqZ3KXMiHRGlU
Message-ID: <CAA4WUYjUJe4jRPfpnLJ2kXmisTri4HsKpiUmpDt_EM_cancU4w@mail.gmail.com>
From: "William Chan (陈智昌)" <willchan@chromium.org>
To: Martin Thomson <martin.thomson@gmail.com>
Cc: Roberto Peon <grmocg@gmail.com>, HTTP Working Group <ietf-http-wg@w3.org>
Content-Type: multipart/alternative; boundary="047d7bdc159e1d956e04d8da5396"
X-Gm-Message-State: ALoCoQmoR1TO3Mwh0q+L7Vssp0T5Z+h5csznmD9EGmVeUnqCE8CpnZgFMOiq5IR20sBYjcVoqR8PxULhwvU7vbbWU6f1Qc+GYFGFnmHj2Qc9AJfSVQBTHWdYr0jZRgI7jnve7leLX6ZoQjhBphvqLq1afvtUBBoYugahXFkVfaAg8jS9Jf9HfYm1AS+QB6QaPP66W4UNx6db
Received-SPF: pass client-ip=209.85.128.52; envelope-from=willchan@google.com; helo=mail-qe0-f52.google.com
X-W3C-Hub-Spam-Status: No, score=-5.1
X-W3C-Hub-Spam-Report: AWL=-1.103, BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, RP_MATCHES_RCVD=-1.302, SPF_PASS=-0.001
X-W3C-Scan-Sig: lisa.w3.org 1UKb77-0005cP-Lj 39527dcf76d926422061977dfeb872a8
X-Original-To: ietf-http-wg@w3.org
Subject: Re: INVALID_STREAM and STREAM_ALREADY_CLOSED
Archived-At: <http://www.w3.org/mid/CAA4WUYjUJe4jRPfpnLJ2kXmisTri4HsKpiUmpDt_EM_cancU4w@mail.gmail.com>
Resent-From: ietf-http-wg@w3.org
X-Mailing-List: <ietf-http-wg@w3.org> archive/latest/17156
X-Loop: ietf-http-wg@w3.org
Resent-Sender: ietf-http-wg-request@w3.org
Precedence: list
List-Id: <ietf-http-wg.w3.org>
List-Help: <http://www.w3.org/Mail/>
List-Post: <mailto:ietf-http-wg@w3.org>
List-Unsubscribe: <mailto:ietf-http-wg-request@w3.org?subject=unsubscribe>

On Tue, Mar 26, 2013 at 1:34 PM, Martin Thomson <martin.thomson@gmail.com>wrote:

> On 26 March 2013 12:58, William Chan (陈智昌) <willchan@chromium.org> wrote:
> > We used INVALID_STREAM to indicate the client received a SYN_STREAM with
> an
> > associated stream id that does not exist. Maybe we should just terminate
> the
> > session.
>
> There are five potential scenarios, all based on the highest stream
> identifier already seen:
>
> 1. Message with a stream ID that is higher than the last stream
> identifier by more than 2.
> Conclusion: No real problem here, just a few gaps in the chain that
> mean less efficient use fo .
>

No real problem, but unexpected and probably undesirable. Any reason to
allow this behavior? Should we make it a session error? Is that overly
strict?


> 2. Message with a stream ID that is lower (or equal to) the highest
> stream identifier.  That stream is still open.
> Conclusion: No problem, that's normal operation.
>
> 3. Message with a stream ID that is lower (or equal to) the highest
> stream identifier.  That stream is (half-)closed.
> Conclusion: STREAM_ALREADY_CLOSED.
>

Does the receiver need to keep the stream in its data structures after it's
closed? It's kind of nice just to throw state away ASAP. But you need that
state around to identify it as already closed.


> 4. Client generates a frame with an even numbered stream ID/server
> uses an odd stream ID. That stream hasn't been used by the peer yet.
> Conclusion: The sender of this frame is supposed to wait for its peer
> to send before using those streams.  This might warrant a separate
> error code.  Is this what INVALID_STREAM is intended to cover?
> Exception: RST_STREAM needs to be valid here to allow PUSH_PROMISE to
> work properly.
>

This is one reason for an invalid stream. What about the associated to
stream id in a PUSH_PROMISE?


>
> 5. Client generates a frame with an even numbered stream ID/server
> uses an odd stream ID. That stream ID has already been used.
> Conclusion: No problem, that's called a reply - normal operation.


Not normal if that stream has already been closed.


>
> > STREAM_ALREADY_CLOSED can be confusing since peers don't necessarily know
> > that it's already closed unless we maintain the set of old closed stream
> > ids.
>
> I never imagined that this would be the case:  If you track open
> streams, as you must, all streams that you aren't tracking are closed
> if they have an ID lower than the highest tracked stream ID.
>

I thought we had a reason why this didn't work, but I do not recall it, so
I'm going to believe you are right here.


>
> > And what if we receive DATA frames for non-existent streams? I guess we
> > shouldn't RST_STREAM a non-existent stream, since the stream id is
> invalid.
>
> Be very clear here.  I like to think of streams as having three
> states: unused, active, and closed.  (Note that you might consider
> these states to apply separately in both directions.)  What states
> correspond to 'non-existent'?  How does one convey an invalid stream
> ID?


I was thinking unused.


>
> On Tue, Mar 26, 2013 at 12:34 PM, Roberto Peon <grmocg@gmail.com> wrote:
> > I expect that we'll expand the error codes as more implementors find
> error
> > conditions that they want to be able to debug from a client debug
> > information, at which point we can re-add any of this.
>
> That is very much true..
>