[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Nonblocking get-bytevector-n bug?
From: |
Marko Rauhamaa |
Subject: |
Nonblocking get-bytevector-n bug? |
Date: |
Sun, 06 Dec 2015 22:38:56 +0200 |
Guile 2.0.11 provides:
get-bytevector-n
get-bytevector-n!
get-bytevector-some
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.
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.
Marko
Re: Nonblocking get-bytevector-n bug?, Amirouche Boubekki, 2015/12/07
Re: Nonblocking get-bytevector-n bug?, Mark H Weaver, 2015/12/08