mirror of
https://github.com/kavishdevar/librepods.git
synced 2026-05-01 02:24:18 +00:00
fix(linux-rust): Retry L2CAP send on ENOTCONN during BlueZ Handshake (#495)
This fix allows the send thread to make 10 attempts to send it's data. This gives access to seeing the battery status
This commit is contained in:
@@ -1233,11 +1233,23 @@ async fn recv_thread(manager: AACPManager, sp: Arc<SeqPacket>) {
|
|||||||
|
|
||||||
async fn send_thread(mut rx: mpsc::Receiver<Vec<u8>>, sp: Arc<SeqPacket>) {
|
async fn send_thread(mut rx: mpsc::Receiver<Vec<u8>>, sp: Arc<SeqPacket>) {
|
||||||
while let Some(data) = rx.recv().await {
|
while let Some(data) = rx.recv().await {
|
||||||
if let Err(e) = sp.send(&data).await {
|
let mut attempts = 0;
|
||||||
error!("Failed to send data: {}", e);
|
loop {
|
||||||
break;
|
match sp.send(&data).await {
|
||||||
|
Ok(_) => {
|
||||||
|
debug!("Sent {} bytes: {}", data.len(), hex::encode(&data));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Err(e) if e.raw_os_error() == Some(107) && attempts < 10 => {
|
||||||
|
attempts += 1;
|
||||||
|
sleep(Duration::from_millis(100)).await;
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
error!("Failed to send data: {}", e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
debug!("Sent {} bytes: {}", data.len(), hex::encode(&data));
|
|
||||||
}
|
}
|
||||||
info!("Send thread finished.");
|
info!("Send thread finished.");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user