Re: [hybi] With deflate-stream, Close frame doesn't work as an end of data marker
Andy Green <andy@warmcat.com> Wed, 09 March 2011 12:34 UTC
Return-Path: <andy.warmcat.com@googlemail.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 B1D683A69A4 for <hybi@core3.amsl.com>; Wed, 9 Mar 2011 04:34:02 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -3.582
X-Spam-Level:
X-Spam-Status: No, score=-3.582 tagged_above=-999 required=5 tests=[AWL=0.017, BAYES_00=-2.599, RCVD_IN_DNSWL_LOW=-1]
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 BoFUDf3fLTfD for <hybi@core3.amsl.com>; Wed, 9 Mar 2011 04:34:01 -0800 (PST)
Received: from mail-wy0-f172.google.com (mail-wy0-f172.google.com [74.125.82.172]) by core3.amsl.com (Postfix) with ESMTP id 501453A696E for <hybi@ietf.org>; Wed, 9 Mar 2011 04:34:01 -0800 (PST)
Received: by wyb42 with SMTP id 42so442054wyb.31 for <hybi@ietf.org>; Wed, 09 Mar 2011 04:35:17 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:sender:message-id:date:from:user-agent :mime-version:to:cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=WXV2ZpOdnme7HlBlY8lNcpG3KjvaFZEa2b2W8oeR86Y=; b=QXAq3Kz0CEBAYYtlGPVPYMRkIOZGP2jYVOF8YcX7wsbwHBzwOmjQUWeh0qLg4WM1S6 /58wFTmKZNU6HOi8uoNRLUZetUJYrIN4Ya5+dHQCxdFjcVcLuXvh3OscFyBaIgJAR4Hm dxa6ieWMDDAqbQKawW52T10Ewg8MAQN3zn/KU=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=U55zoC7MdFe3DVabHohpo41RNo5OnL7i82pau2Xa1saF/d7D7X3yeZeiUlM79z+mSj KP+0SOG98Ye73S9nleV6Hf+ef8K5fssz3rIxvYUghA9rfzAF8QX5yGl1YBb+35qfxYbj lDYuawrR4e37ZUeA1F13y+IfDtW+YwYWpvTXo=
Received: by 10.227.139.19 with SMTP id c19mr894404wbu.13.1299674116798; Wed, 09 Mar 2011 04:35:16 -0800 (PST)
Received: from otae.warmcat.com (s15404224.onlinehome-server.info [87.106.134.80]) by mx.google.com with ESMTPS id o6sm1432134wbo.9.2011.03.09.04.35.15 (version=SSLv3 cipher=OTHER); Wed, 09 Mar 2011 04:35:15 -0800 (PST)
Sender: Andy Green <andy.warmcat.com@googlemail.com>
Message-ID: <4D777402.3010101@warmcat.com>
Date: Wed, 09 Mar 2011 12:35:14 +0000
From: Andy Green <andy@warmcat.com>
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110302 Fedora/3.1.8-3.fc16 Thunderbird/3.1.8
MIME-Version: 1.0
To: Takeshi Yoshino <tyoshino@google.com>
References: <OF27A0495D.2C32912B-ON8825784E.00342DCE-8825784E.00367A85@playstation.sony.com> <4D775D69.8010808@warmcat.com> <AANLkTi=4_jp_=QffTsTbrUxjzGTRTv5F4Ao=5ZBpc2FB@mail.gmail.com>
In-Reply-To: <AANLkTi=4_jp_=QffTsTbrUxjzGTRTv5F4Ao=5ZBpc2FB@mail.gmail.com>
Content-Type: text/plain; charset="ISO-8859-1"; format="flowed"
Content-Transfer-Encoding: 7bit
Cc: hybi@ietf.org, Yutaka_Takeda@playstation.sony.com
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: Wed, 09 Mar 2011 12:34:02 -0000
On 03/09/2011 12:06 PM, Somebody in the thread at some point said: Hi - > Having implemented this now, I don't see the problem using > Z_PARTIAL_FLUSH as the standard seems to recommend normally, and > then Z_FULL_FLUSH when sending the close packet, and disabling any > further packet issue on that connection. So I don't think Takeshi's > issue is more than an implementation problem, I'd welcome being > educated if I missed any point. > > > Maybe, exhaustive (to be strict, recv with big buffer) recv call in your > code drains all the deflated data arrived (everything including Huffman > codes for some preceding frames, ones for close frame, 3 bit header > BFINAL=0 BTYPE=00 and 00 00 ff ff) from the TCP stack. Yes on both rx / inflate and tx / deflate case libwebsockets will always loop and go back to in/deflate() for the rest if the callback handling that indicates the zlib call filled its spill buffer (suggesting that it very likely has more to spill). So if there are multiple buffers full of stuff to flush in both rx or tx path they will always all get sent on the wire or sent to the user callback as uncompressed rx data before moving on. You can see the loop here for the tx path http://git.warmcat.com/cgi-bin/cgit/libwebsockets/tree/lib/parsers.c#n1378 After issuing specifically the CLOSE opcode packet like that, the connection state is changed so nothing more can be emitted on the socket, and this works reliably to issue the CLOSE to the far end for sure without further zlib housekeeping traffic or any other traffic going out. > Yes, since it's rare that octets for a single WebSocket frame are put in > separate TCP packets and delivered to application layer separately > (requiring separate recv-call), this is not a big problem. But with > in-frame compression, it becomes perfect. I think you must handle extreme compression cases anyway to keep an eye on latency if nothing else, consider he sends 200K of 0x00 and the compressor run-length encodes it, you receive a handful of compressed code bytes but must sit looping through 200K of decompressed content that represents one message. Or you pass in 1K of high quality random and 3K of codes comes out of the compressor. Like I say I think keeping framing out of compression is okay, just deflate-stream babbling after close isn't any reason for it AFAICS. -Andy
- [hybi] With deflate-stream, Close frame doesn't w… Takeshi Yoshino
- Re: [hybi] With deflate-stream, Close frame doesn… Yutaka_Takeda
- Re: [hybi] With deflate-stream, Close frame doesn… Takeshi Yoshino
- Re: [hybi] With deflate-stream, Close frame doesn… Yutaka_Takeda
- Re: [hybi] With deflate-stream / websocket tracer… Andy Green
- Re: [hybi] With deflate-stream, Close frame doesn… Takeshi Yoshino
- Re: [hybi] With deflate-stream, Close frame doesn… Yutaka_Takeda
- Re: [hybi] With deflate-stream / websocket tracer… John Tamplin
- Re: [hybi] With deflate-stream / websocket tracer… Andy Green
- Re: [hybi] With deflate-stream, Close frame doesn… Greg Wilkins
- Re: [hybi] With deflate-stream, Close frame doesn… John Tamplin
- Re: [hybi] With deflate-stream, Close frame doesn… Greg Wilkins
- Re: [hybi] With deflate-stream, Close frame doesn… Brian McKelvey
- Re: [hybi] With deflate-stream, Close frame doesn… Yutaka_Takeda
- Re: [hybi] With deflate-stream, Close frame doesn… Yutaka_Takeda
- Re: [hybi] With deflate-stream, Close frame doesn… Andy Green
- Re: [hybi] With deflate-stream, Close frame doesn… Takeshi Yoshino
- Re: [hybi] With deflate-stream, Close frame doesn… Andy Green
- Re: [hybi] With deflate-stream, Close frame doesn… Takeshi Yoshino
- Re: [hybi] With deflate-stream, Close frame doesn… Andy Green
- Re: [hybi] With deflate-stream, Close frame doesn… Takeshi Yoshino
- Re: [hybi] With deflate-stream, Close frame doesn… Yutaka_Takeda
- Re: [hybi] With deflate-stream, Close frame doesn… Andy Green
- Re: [hybi] With deflate-stream, Close frame doesn… Ian Fette (イアンフェッティ)
- [hybi] change in 07: Payload only compression ext… Salvatore Loreto
- Re: [hybi] change in 07: Payload only compression… Ian Fette (イアンフェッティ)
- Re: [hybi] change in 07: Payload only compression… Brian
- Re: [hybi] With deflate-stream, Close frame doesn… Andy Green
- [hybi] TCP packet boundaries must not be assumed … Jamie Lokier
- Re: [hybi] With deflate-stream, Close frame doesn… Jamie Lokier
- Re: [hybi] With deflate-stream, Close frame doesn… Takeshi Yoshino
- Re: [hybi] With deflate-stream, Close frame doesn… Andy Green
- Re: [hybi] TCP packet boundaries must not be assu… Andy Green
- Re: [hybi] With deflate-stream, Close frame doesn… Takeshi Yoshino
- Re: [hybi] With deflate-stream, Close frame doesn… John Tamplin
- Re: [hybi] With deflate-stream, Close frame doesn… Takeshi Yoshino