fix: 读帧遇信号中断重试

This commit is contained in:
2026-10-08 01:55:49 +00:00
parent 372bb80cfd
commit a1e2d7c762
2 changed files with 7 additions and 2 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ members = [
]
[workspace.package]
version = "0.8.56"
version = "0.8.57"
edition = "2021"
license = "MIT"
rust-version = "1.80"
+6 -1
View File
@@ -350,8 +350,13 @@ impl<R: BufRead> FrameReader<R> {
}
// 从流读一块追加到余量缓冲。
// 信号中断(EINTR)不视为错误:重试读,保持读循环不变式。
let mut chunk = [0u8; 4096];
let n = self.inner.read(&mut chunk)?;
let n = match self.inner.read(&mut chunk) {
Ok(n) => n,
Err(e) if e.kind() == std::io::ErrorKind::Interrupted => continue,
Err(e) => return Err(e),
};
if n == 0 {
// EOF:余量缓冲的残行原样交付(可能为空)。
let line = std::mem::take(&mut self.pending);