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:
parent
a043eaf349
commit
b55397ea5d
1 changed files with 5 additions and 1 deletions
|
@ -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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue