mirror of
https://github.com/jkcoxson/idevice.git
synced 2026-03-02 14:36:16 +01:00
Add adapter_close to stop TCP stack
This commit is contained in:
@@ -38,6 +38,7 @@ enum HandleMessage {
|
||||
path: PathBuf,
|
||||
res: oneshot::Sender<Result<(), std::io::Error>>,
|
||||
},
|
||||
Die,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -90,6 +91,9 @@ impl AdapterHandle {
|
||||
res
|
||||
} => {
|
||||
res.send(adapter.pcap(path).await).ok();
|
||||
},
|
||||
HandleMessage::Die => {
|
||||
break;
|
||||
}
|
||||
},
|
||||
Err(_) => {
|
||||
@@ -218,6 +222,16 @@ impl AdapterHandle {
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn close(&mut self) -> Result<(), std::io::Error> {
|
||||
if self.sender.send(HandleMessage::Die).is_err() {
|
||||
return Err(std::io::Error::new(
|
||||
std::io::ErrorKind::NetworkUnreachable,
|
||||
"adapter closed",
|
||||
));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
||||
Reference in New Issue
Block a user