1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-29 19:30:36 +02:00

Make `read-bytes' suspendable for socket reads on MinGW.

On MinGW, port-read will block on sockets if no data is available.
Avoid blocking by using select first.

* module/ice-9/suspendable-ports.scm (read-bytes): For socket ports,
guard port-read with select.
This commit is contained in:
Jan (janneke) Nieuwenhuizen 2020-03-27 21:29:23 +01:00 committed by Michael Gran
parent a043eaf349
commit b55397ea5d

View file

@ -68,8 +68,12 @@
(define (wait-for-writable port) ((current-write-waiter) port))
(define (read-bytes port dst start count)
(define (socket? port)
(string-prefix? "#<input-output: socket" (format #f "~a" port)))
(cond
(((port-read port) port dst start count)
((and (or (not (socket? port))
(pair? (car (select (list port) '() '() 0 0))))
((port-read port) port dst start count))
=> (lambda (read)
(unless (<= 0 read count)
(error "bad return from port read function" read))