fix: TUI reader-loop — silent timeout handling, sleep on idle
Some checks failed
Deploy (Gitea) / deploy (push) Failing after 2s
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:
@@ -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
|
||||
|
||||
@@ -207,23 +207,25 @@ Event handlers + daemon I/O + main loop.
|
||||
(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)))))
|
||||
#+end_src
|
||||
|
||||
** Connection
|
||||
|
||||
Reference in New Issue
Block a user