[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 09/16: Make `read-bytes' suspendable for socket reads on
From: |
Jan Nieuwenhuizen |
Subject: |
[Guile-commits] 09/16: Make `read-bytes' suspendable for socket reads on MinGW. |
Date: |
Mon, 16 May 2022 14:23:38 -0400 (EDT) |
janneke pushed a commit to branch wip-mingw
in repository guile.
commit c45224ae6093c30d3a54aa02f0bfddb375c64e82
Author: Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
AuthorDate: Fri Mar 27 21:29:23 2020 +0100
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.
---
module/ice-9/suspendable-ports.scm | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/module/ice-9/suspendable-ports.scm
b/module/ice-9/suspendable-ports.scm
index a823f1d37..a451b63f1 100644
--- a/module/ice-9/suspendable-ports.scm
+++ b/module/ice-9/suspendable-ports.scm
@@ -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))
- [Guile-commits] 10/16: Install 'mingw_take_signal' on MinGW., (continued)
- [Guile-commits] 10/16: Install 'mingw_take_signal' on MinGW., Jan Nieuwenhuizen, 2022/05/16
- [Guile-commits] 01/16: gnulib: Import the gethostname module., Jan Nieuwenhuizen, 2022/05/16
- [Guile-commits] 02/16: Link fix for MinGW., Jan Nieuwenhuizen, 2022/05/16
- [Guile-commits] 05/16: Support for x86_64-w64-mingw32., Jan Nieuwenhuizen, 2022/05/16
- [Guile-commits] 14/16: REMOVEME mingw: Hardcode compile-time-file-name-convention to 'mingw., Jan Nieuwenhuizen, 2022/05/16
- [Guile-commits] 16/16: DEBUG guile.cmd, wine-guile.sh: Some Wine help., Jan Nieuwenhuizen, 2022/05/16
- [Guile-commits] 08/16: squash! Fix 'absolute-file-name?' and others for cross-build to MinGW., Jan Nieuwenhuizen, 2022/05/16
- [Guile-commits] 12/16: DRAFT Add partial `scm_fcntl' support for MinGW., Jan Nieuwenhuizen, 2022/05/16
- [Guile-commits] 13/16: guix: Add guile-patched, guile-mingw., Jan Nieuwenhuizen, 2022/05/16
- [Guile-commits] 15/16: REMOVEME guix: guile-mingw: Hardcode file-name-convention., Jan Nieuwenhuizen, 2022/05/16
- [Guile-commits] 09/16: Make `read-bytes' suspendable for socket reads on MinGW.,
Jan Nieuwenhuizen <=
- [Guile-commits] 11/16: Add `scm_sigaction_for_thread' stub for MinGW., Jan Nieuwenhuizen, 2022/05/16
- [Guile-commits] 07/16: Fix 'absolute-file-name?' and others for cross-build to MinGW., Jan Nieuwenhuizen, 2022/05/16