fix: TUI reader-loop — silent timeout handling, sleep on idle
Some checks failed
Deploy (Gitea) / deploy (push) Failing after 2s

- recv-daemon: catch all errors silently (not just usocket:timeout-error
  which doesn't match SBCL's SB-INT:IO-TIMEOUT). Prevents log-message
  from bleeding through to the Croatoan screen.
- reader-loop: add (sleep 0.5) when recv-daemon returns nil, preventing
  tight spin on repeated I/O timeouts during idle periods.
This commit is contained in:
2026-05-06 10:25:11 -04:00
parent 183aeeedb8
commit 9130e08e92
2 changed files with 16 additions and 12 deletions

View File

@@ -176,23 +176,25 @@
(let* ((hdr (make-string 6)) (n 0))
(loop while (< n 6)
do (let ((ch (read-char s nil)))
(unless ch (return-from recv-daemon nil))
(setf (char hdr n) ch) (incf n)))
(unless ch (return-from recv-daemon nil))
(setf (char hdr n) ch) (incf n)))
(let* ((len (parse-integer hdr :radix 16 :junk-allowed t))
(buf (make-string (or len 0))))
(when (and len (> len 0))
(loop for i from 0 below len
do (let ((ch (read-char s nil)))
(unless ch (return-from recv-daemon nil))
(setf (char buf i) ch)))
(unless ch (return-from recv-daemon nil))
(setf (char buf i) ch)))
(let ((*read-eval* nil))
(read-from-string buf)))))
(error (c) (log-message "TUI-RECV: ~a" c) nil)))
(error () nil)))
(defun reader-loop (s)
(loop while (and (st :running) (open-stream-p s))
do (let ((msg (recv-daemon s)))
(when msg (queue-event (list :type :daemon :payload msg))))))
(if msg
(queue-event (list :type :daemon :payload msg))
(sleep 0.5)))))
(defun connect-daemon (&optional (host "127.0.0.1") (port 9105))
(handler-case