mirror of
https://github.com/jkcoxson/idevice.git
synced 2026-03-02 22:46:14 +01:00
Propogate stack errors to handle callers
This commit is contained in:
@@ -581,7 +581,7 @@ impl Adapter {
|
||||
}
|
||||
if res.flags.fin {
|
||||
ack_me = Some(res.destination_port);
|
||||
state.status = ConnectionStatus::Error(ErrorKind::ConnectionReset);
|
||||
state.status = ConnectionStatus::Error(ErrorKind::UnexpectedEof);
|
||||
}
|
||||
if res.flags.syn && res.flags.ack {
|
||||
ack_me = Some(res.destination_port);
|
||||
|
||||
@@ -14,6 +14,8 @@ use tokio::{
|
||||
sync::oneshot,
|
||||
};
|
||||
|
||||
use crate::tcp::adapter::ConnectionStatus;
|
||||
|
||||
pub type ConnectToPortRes =
|
||||
oneshot::Sender<Result<(u16, AsyncRx<Result<Vec<u8>, std::io::Error>>), std::io::Error>>;
|
||||
|
||||
@@ -124,6 +126,23 @@ impl AdapterHandle {
|
||||
handles.remove(&hp);
|
||||
let _ = adapter.close(hp).await;
|
||||
}
|
||||
|
||||
let mut to_close = Vec::new();
|
||||
for (&hp, tx) in &handles {
|
||||
if let Ok(ConnectionStatus::Error(kind)) = adapter.get_status(hp) {
|
||||
if kind == std::io::ErrorKind::UnexpectedEof {
|
||||
to_close.push(hp);
|
||||
} else {
|
||||
let _ = tx.send(Err(std::io::Error::from(kind)));
|
||||
to_close.push(hp);
|
||||
}
|
||||
}
|
||||
}
|
||||
for hp in to_close {
|
||||
handles.remove(&hp);
|
||||
// Best-effort close. For RST this just tidies state on our side
|
||||
let _ = adapter.close(hp).await;
|
||||
}
|
||||
}
|
||||
|
||||
_ = tick.tick() => {
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::{
|
||||
time::{SystemTime, UNIX_EPOCH},
|
||||
};
|
||||
|
||||
use log::debug;
|
||||
use log::trace;
|
||||
use tokio::io::AsyncWriteExt;
|
||||
|
||||
use crate::{ReadWrite, provider::RsdProvider};
|
||||
@@ -16,7 +16,7 @@ pub mod packets;
|
||||
pub mod stream;
|
||||
|
||||
pub(crate) fn log_packet(file: &Arc<tokio::sync::Mutex<tokio::fs::File>>, packet: &[u8]) {
|
||||
debug!("Logging {} byte packet", packet.len());
|
||||
trace!("Logging {} byte packet", packet.len());
|
||||
let packet = packet.to_vec();
|
||||
let file = file.to_owned();
|
||||
let now = SystemTime::now();
|
||||
|
||||
Reference in New Issue
Block a user