From 1f02eabb8058f513baf6018329e55e0140021f36 Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Fri, 12 Jan 2024 22:44:22 -0800 Subject: Handle Interrupted errors during read. --- src/rope.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/rope.rs b/src/rope.rs index b5b5f36..485de7f 100644 --- a/src/rope.rs +++ b/src/rope.rs @@ -1,4 +1,4 @@ -use std::io::{Read, Write}; +use std::io::{ErrorKind, Read, Write}; use std::rc::Rc; const MAX_NODE_SIZE: usize = 1024; @@ -214,7 +214,15 @@ impl Rope { let mut buf = vec![0; MAX_NODE_SIZE]; let mut rope = Rope::empty(); loop { - let n = r.read(&mut buf)?; + let n = match r.read(&mut buf) { + Ok(n) => n, + Err(err) => { + if err.kind() == ErrorKind::Interrupted { + continue; + } + return Err(err); + } + }; if n == 0 { break; } -- cgit v1.3.1