Re: [hybi] With deflate-stream, Close frame doesn't work as an end of data marker

Takeshi Yoshino <tyoshino@google.com> Thu, 24 February 2011 13:11 UTC

Return-Path: <tyoshino@google.com>
X-Original-To: hybi@core3.amsl.com
Delivered-To: hybi@core3.amsl.com
Received: from localhost (localhost [127.0.0.1]) by core3.amsl.com (Postfix) with ESMTP id 9CA593A6B0E for <hybi@core3.amsl.com>; Thu, 24 Feb 2011 05:11:21 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -105.659
X-Spam-Level:
X-Spam-Status: No, score=-105.659 tagged_above=-999 required=5 tests=[AWL=0.317, BAYES_00=-2.599, FM_FORGED_GMAIL=0.622, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_MED=-4, USER_IN_WHITELIST=-100]
Received: from mail.ietf.org ([64.170.98.32]) by localhost (core3.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id S5Bz+cYV2gHP for <hybi@core3.amsl.com>; Thu, 24 Feb 2011 05:11:20 -0800 (PST)
Received: from smtp-out.google.com (smtp-out.google.com [216.239.44.51]) by core3.amsl.com (Postfix) with ESMTP id 21EE53A6AFC for <hybi@ietf.org>; Thu, 24 Feb 2011 05:11:19 -0800 (PST)
Received: from hpaq2.eem.corp.google.com (hpaq2.eem.corp.google.com [172.25.149.2]) by smtp-out.google.com with ESMTP id p1ODC70b019132 for <hybi@ietf.org>; Thu, 24 Feb 2011 05:12:08 -0800
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta; t=1298553128; bh=yi6lOFfd3j5/j0HHr2UoPYUNphE=; h=MIME-Version:In-Reply-To:References:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=IlpLjMMeDzbcudIUFgdLaFIObzghR/Jes02bl0l+vnu60844kMONXmmunE8Z7uRoS p7JHrPcg5HnmIkP8AlxPA==
Received: from iyj12 (iyj12.prod.google.com [10.241.51.76]) by hpaq2.eem.corp.google.com with ESMTP id p1ODC5l9005327 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for <hybi@ietf.org>; Thu, 24 Feb 2011 05:12:06 -0800
Received: by iyj12 with SMTP id 12so293584iyj.13 for <hybi@ietf.org>; Thu, 24 Feb 2011 05:12:05 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=beta; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=hOJ6KGcL7igIu1gXiYPgIiqZnPaDgCvXaUlVHFP5nW8=; b=CfptA6RY/rFJWiDROneVjcphGFAjTF3iIJzdj7wEgqK7zWYckFgCgwXSU6sgZSmDbH 8o0y7PhnpbHmJnaOI6Kg==
DomainKey-Signature: a=rsa-sha1; c=nofws; d=google.com; s=beta; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=AmgflFCZB4fzPw4+dxcBSruqvvIo33efaeRmC9tN4/oR8wsdXEU22Q0E+7Y1DJYW/P Ou4lF55e1lh3B6rtlQgg==
Received: by 10.231.206.197 with SMTP id fv5mr1411894ibb.84.1298553124961; Thu, 24 Feb 2011 05:12:04 -0800 (PST)
MIME-Version: 1.0
Received: by 10.231.17.201 with HTTP; Thu, 24 Feb 2011 05:11:09 -0800 (PST)
In-Reply-To: <OFC19D8FEF.225C2E75-ON8825783A.00827B4C-8825783B.00031959@playstation.sony.com>
References: <AANLkTimyGWacfoVFon1TsQzqmsEcKy9tNsmKhCnJhgWM@mail.gmail.com> <OFC19D8FEF.225C2E75-ON8825783A.00827B4C-8825783B.00031959@playstation.sony.com>
From: Takeshi Yoshino <tyoshino@google.com>
Date: Thu, 24 Feb 2011 22:11:09 +0900
Message-ID: <AANLkTinVwPRpo7NgJjf3+6gcrBHaJugT9OugKKAsMU9X@mail.gmail.com>
To: Yutaka_Takeda@playstation.sony.com
Content-Type: multipart/alternative; boundary="90e6ba4fc248bc3db6049d06f53b"
X-System-Of-Record: true
Cc: hybi@ietf.org
Subject: Re: [hybi] With deflate-stream, Close frame doesn't work as an end of data marker
X-BeenThere: hybi@ietf.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Server-Initiated HTTP <hybi.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/listinfo/hybi>, <mailto:hybi-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/hybi>
List-Post: <mailto:hybi@ietf.org>
List-Help: <mailto:hybi-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/hybi>, <mailto:hybi-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 24 Feb 2011 13:11:22 -0000

On Fri, Feb 18, 2011 at 09:33, <Yutaka_Takeda@playstation.sony.com> wrote:

>
> Hi Takeshi,
>
> Good point. There is indeed a legitmate case where trailing bytes is
> present after
> Close frame.
>

It is important to note that after endpoint sent and received Close frame,
> it is considered
> that WebSocket layer close handshake has been complete ('wasClear' gets set
> to 1,
> etc.).
>
> What Takeshi pointed out is a good motivation for WS-layer to perform
> graceful
> shutdown at TCP layer as well. After Close frame has been exchanged
> successfully,
> the endpoint must start shutting down the local TCP connection with
> shutdown(SHUT_WR), and discard the trailing bytes, if any received, and
> then finally
> close the socket on receipt of EoS.
>

This works for any trailing bytes that could be caused by artifact of
> another deflate
> algorithm that may be introduced in the future, or just by a bug.
>
>
For this case, we can take another way without depending on TCP FIN
- have deflater compress Closing frame in BFINAL block (flush with Z_FINISH)
- have inflater drain compressed stream until it see EOB

This might work for most environments, but not all library/wrapper of zlib
expose API to recognize EOB/BFINAL immediately. For example, zlib module of
Python doesn't. See the explanation of zlib.Decompress.unused_data. If we
move Close frame out of compressed stream, we can use this, but it
complicates protocol.

I agree that using SHUT_WR + EoS is nice on platforms where they're
available, but I still want to provide a way that deals with this issue
without depending on them if possible.

Takeshi