Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gio: Fix panics if PollableInputStream / PollableOutputStream ret… #1159

Merged
merged 1 commit into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion gio/src/pollable_input_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ impl<T: IsA<PollableInputStream>> AsyncRead for InputStreamAsyncRead<T> {
match gio_result {
Ok(size) => Poll::Ready(Ok(size as usize)),
Err(err) => {
let kind = err.kind::<crate::IOErrorEnum>().unwrap();
let kind = err
.kind::<crate::IOErrorEnum>()
.unwrap_or(crate::IOErrorEnum::Failed);
if kind == crate::IOErrorEnum::WouldBlock {
let mut waker = Some(cx.waker().clone());
let source = stream.0.as_ref().create_source(
Expand Down
9 changes: 7 additions & 2 deletions gio/src/pollable_output_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,9 @@ impl<T: IsA<PollableOutputStream>> AsyncWrite for OutputStreamAsyncWrite<T> {
match gio_result {
Ok(size) => Poll::Ready(Ok(size as usize)),
Err(err) => {
let kind = err.kind::<crate::IOErrorEnum>().unwrap();
let kind = err
.kind::<crate::IOErrorEnum>()
.unwrap_or(crate::IOErrorEnum::Failed);
if kind == crate::IOErrorEnum::WouldBlock {
let mut waker = Some(cx.waker().clone());
let source = stream.0.as_ref().create_source(
Expand Down Expand Up @@ -245,7 +247,10 @@ impl<T: IsA<PollableOutputStream>> AsyncWrite for OutputStreamAsyncWrite<T> {
}
Ok((_, _)) => unreachable!(),
Err(err) => Poll::Ready(Err(io::Error::new(
io::ErrorKind::from(err.kind::<crate::IOErrorEnum>().unwrap()),
io::ErrorKind::from(
err.kind::<crate::IOErrorEnum>()
.unwrap_or(crate::IOErrorEnum::Failed),
),
err,
))),
}
Expand Down
Loading