Flush socket after write

Rustls doesn't automatically flush data after write, causing deadlocks
when waiting for a response.
This commit is contained in:
Jackson Coxson
2025-04-06 23:19:23 -06:00
parent 68e1787231
commit b89639ad47
2 changed files with 4 additions and 3 deletions

View File

@@ -184,6 +184,7 @@ impl Idevice {
let len = message.len() as u32; let len = message.len() as u32;
socket.write_all(&len.to_be_bytes()).await?; socket.write_all(&len.to_be_bytes()).await?;
socket.write_all(message.as_bytes()).await?; socket.write_all(message.as_bytes()).await?;
socket.flush().await?;
Ok(()) Ok(())
} else { } else {
Err(IdeviceError::NoEstablishedConnection) Err(IdeviceError::NoEstablishedConnection)
@@ -233,6 +234,7 @@ impl Idevice {
socket.write_all(part).await?; socket.write_all(part).await?;
callback(((i, part_len), state.clone())).await; callback(((i, part_len), state.clone())).await;
} }
socket.flush().await?;
Ok(()) Ok(())
} else { } else {
Err(IdeviceError::NoEstablishedConnection) Err(IdeviceError::NoEstablishedConnection)
@@ -330,7 +332,7 @@ impl Idevice {
let socket = self.socket.take().unwrap(); let socket = self.socket.take().unwrap();
let socket = connector let socket = connector
.connect(ServerName::try_from("iOS").unwrap(), socket) .connect(ServerName::try_from("Device").unwrap(), socket)
.await?; .await?;
self.socket = Some(Box::new(socket)); self.socket = Some(Box::new(socket));

View File

@@ -10,6 +10,7 @@
use log::debug; use log::debug;
use crate::{lockdown::LockdownClient, Idevice, IdeviceError, IdeviceService}; use crate::{lockdown::LockdownClient, Idevice, IdeviceError, IdeviceService};
use sha2::{Digest, Sha384};
#[cfg(feature = "tss")] #[cfg(feature = "tss")]
use crate::tss::TSSRequest; use crate::tss::TSSRequest;
@@ -539,7 +540,6 @@ impl ImageMounter {
S: Clone, S: Clone,
{ {
// Try to fetch personalization manifest // Try to fetch personalization manifest
use sha2::{Digest, Sha384};
let mut hasher = Sha384::new(); let mut hasher = Sha384::new();
hasher.update(&image); hasher.update(&image);
let image_hash = hasher.finalize(); let image_hash = hasher.finalize();
@@ -776,4 +776,3 @@ impl ImageMounter {
} }
} }
} }