Skip to content

Commit a5e8c4e

Browse files
committed
Open fifo twice to have independent file descriptor
So that setting `O_NONBLOCK` would not affect other. Signed-off-by: Jiahao XU <[email protected]>
1 parent 997ffb6 commit a5e8c4e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/unix.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,17 @@ impl Client {
114114
})?;
115115
let path = Path::new(path_str);
116116

117-
let file = OpenOptions::new()
118-
.read(true)
119-
.write(true)
120-
.open(path)
121-
.map_err(|err| FromEnvErrorInner::CannotOpenPath(path_str.to_string(), err))?;
117+
let open_file = || {
118+
OpenOptions::new()
119+
.read(true)
120+
.write(true)
121+
.open(path)
122+
.map_err(|err| FromEnvErrorInner::CannotOpenPath(path_str.to_string(), err))
123+
};
122124

123125
Ok(Some(Client {
124-
read: file
125-
.try_clone()
126-
.map_err(|err| FromEnvErrorInner::CannotClone(file.as_raw_fd(), err))?,
127-
write: file,
126+
read: open_file()?,
127+
write: open_file()?,
128128
creation_arg: ClientCreationArg::Fifo(path.into()),
129129
is_non_blocking: Some(AtomicBool::new(false)),
130130
}))

0 commit comments

Comments
 (0)