fix: read-raw-byte checks poll result before unix-read
The original code called unix-simple-poll then unconditionally called unix-read, ignoring the poll result. When poll returned nil (no data), unix-read would block indefinitely. Fixed by checking poll result: only read if poll says data is ready.
This commit is contained in:
@@ -74,9 +74,11 @@
|
|||||||
(sb-sys:with-pinned-objects (buf)
|
(sb-sys:with-pinned-objects (buf)
|
||||||
(let ((sap (sb-sys:vector-sap buf)))
|
(let ((sap (sb-sys:vector-sap buf)))
|
||||||
(if timeout-ms
|
(if timeout-ms
|
||||||
(progn (sb-unix:unix-simple-poll fd :input timeout-ms)
|
;; Poll first: only read if data is ready
|
||||||
(let ((n (sb-unix:unix-read fd sap 1)))
|
(if (sb-unix:unix-simple-poll fd :input timeout-ms)
|
||||||
(if (= n 1) (aref buf 0) (values nil :eof))))
|
(let ((n (sb-unix:unix-read fd sap 1)))
|
||||||
|
(if (= n 1) (aref buf 0) (values nil :eof)))
|
||||||
|
nil)
|
||||||
(let ((n (sb-unix:unix-read fd sap 1)))
|
(let ((n (sb-unix:unix-read fd sap 1)))
|
||||||
(if (= n 1) (aref buf 0) (values nil :eof))))))))
|
(if (= n 1) (aref buf 0) (values nil :eof))))))))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user