Skip to content

Commit 1806f01

Browse files
committed
io_uring: add error handling for accessory device opening
1 parent 6bcc2cf commit 1806f01

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/io_uring.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -298,14 +298,21 @@ pub async fn io_loop(
298298
"{} 📂 Opening USB accessory device: <u>{}</u>",
299299
NAME, USB_ACCESSORY_PATH
300300
);
301-
hu_usb = Some(
302-
OpenOptions::new()
303-
.read(true)
304-
.write(true)
305-
.create(false)
306-
.open(USB_ACCESSORY_PATH)
307-
.await?,
308-
);
301+
match OpenOptions::new()
302+
.read(true)
303+
.write(true)
304+
.create(false)
305+
.open(USB_ACCESSORY_PATH)
306+
.await
307+
{
308+
Ok(s) => hu_usb = Some(s),
309+
Err(e) => {
310+
error!("{} 🔴 Error opening USB accessory: {}", NAME, e);
311+
// notify main loop to restart
312+
need_restart.notify_one();
313+
continue;
314+
}
315+
}
309316
}
310317

311318
info!("{} ♾️ Starting to proxy data between HU and MD...", NAME);

0 commit comments

Comments
 (0)