From 19888e97aab635b8adf1890e2020cf060736ac04 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Tue, 11 Dec 2012 20:16:28 +0000 Subject: [PATCH] Fix READ-PACKET in swank.scm to cope with partial reads. Thanks, ecraven. --- src/runtime/swank.scm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/runtime/swank.scm b/src/runtime/swank.scm index 48239cf71..77bb51c78 100644 --- a/src/runtime/swank.scm +++ b/src/runtime/swank.scm @@ -144,8 +144,15 @@ USA. (dispatch (decode-message socket (read-packet socket)) socket level)) (define (read-packet in) - (if (eof-object? (peek-char in)) - (disconnect)) + (define (read-string! buffer in) + (let loop ((i 0)) + (if (< i (string-length buffer)) + (let ((n (read-substring! buffer i (string-length buffer) in))) + ;; (assert (exact-nonnegative-integer? n)) + ;; (assert (<= n (- (string-length buffer) i))) + (if (zero? n) ;EOF + (disconnect)) + (loop (+ i n)))))) (let ((buffer (make-string (let ((buffer (make-string 6))) -- 2.25.1