From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Newsgroups: gmane.lisp.guile.user Subject: Re: Nonblocking get-bytevector-n bug? Date: Mon, 07 Dec 2015 10:50:51 +0100 Message-ID: <87poyilh8k.fsf@gnu.org> References: <87h9jvuxb3.fsf@elektro.pacujo.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1449481887 3207 80.91.229.3 (7 Dec 2015 09:51:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 7 Dec 2015 09:51:27 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Dec 07 10:51:17 2015 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1a5sRv-0005o7-98 for guile-user@m.gmane.org; Mon, 07 Dec 2015 10:51:15 +0100 Original-Received: from localhost ([::1]:53529 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a5sRu-00076x-Kj for guile-user@m.gmane.org; Mon, 07 Dec 2015 04:51:14 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40779) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a5sRk-00076s-Ff for guile-user@gnu.org; Mon, 07 Dec 2015 04:51:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a5sRh-0000RB-7X for guile-user@gnu.org; Mon, 07 Dec 2015 04:51:04 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:59552) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a5sRh-0000R5-0x for guile-user@gnu.org; Mon, 07 Dec 2015 04:51:01 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1a5sRe-0005IT-FC for guile-user@gnu.org; Mon, 07 Dec 2015 10:50:58 +0100 Original-Received: from pluto.bordeaux.inria.fr ([193.50.110.57]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 07 Dec 2015 10:50:58 +0100 Original-Received: from ludo by pluto.bordeaux.inria.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 07 Dec 2015 10:50:58 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 47 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: pluto.bordeaux.inria.fr X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 17 Frimaire an 224 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x3D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-unknown-linux-gnu User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) Cancel-Lock: sha1:vlQGyXY4wy6JGPfYi7ueFBnmx9c= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:12217 Archived-At: Marko Rauhamaa skribis: > Of these, only get-bytevector-some seems to behave as expected when the > port is nonblocking: > > ======================================================================== > (use-modules (rnrs io ports) > (rnrs bytevectors)) > > (let ((port (fdes->inport 0))) > (fcntl port F_SETFL (logior O_NONBLOCK (fcntl port F_GETFL))) > (let loop () > (catch 'system-error > (lambda () > (format #t "~s\n" (get-bytevector-some port))) > (lambda syserr > (format #t "err ~s\n" (system-error-errno syserr)))) > (sleep 1) > (loop))) > ======================================================================== > > If you replace (get-bytevector-some port) with > (get-bytevector-n port 8192) or (get-bytevector-n! port bv 0 8192), > no partial data is returned. That’s because get-bytevector-n{,!} are specified as blocking if necessary until N bytes are read or EOF is reached. > The problem with get-bytevector-some is that there is no limit to how > many bytes might be returned. In practice, I see that the amount is > capped at 4096 bytes, but the documentation does not guarantee any > limit. Right, the R6RS specification of that procedure doesn’t tell anything more either. It was criticized back in the day partly for that reason: http://www.r6rs.org/formal-comments/comment-224.txt I think a ‘get-bytevector-some!’ procedure could address the issue. Not sure what R7 does here. Thoughts? Ludo’.