File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1233,11 +1233,23 @@ async fn recv_thread(manager: AACPManager, sp: Arc<SeqPacket>) {
12331233
12341234async fn send_thread ( mut rx : mpsc:: Receiver < Vec < u8 > > , sp : Arc < SeqPacket > ) {
12351235 while let Some ( data) = rx. recv ( ) . await {
1236- if let Err ( e) = sp. send ( & data) . await {
1237- error ! ( "Failed to send data: {}" , e) ;
1238- break ;
1236+ let mut attempts = 0 ;
1237+ loop {
1238+ match sp. send ( & data) . await {
1239+ Ok ( _) => {
1240+ debug ! ( "Sent {} bytes: {}" , data. len( ) , hex:: encode( & data) ) ;
1241+ break ;
1242+ }
1243+ Err ( e) if e. raw_os_error ( ) == Some ( 107 ) && attempts < 10 => {
1244+ attempts += 1 ;
1245+ sleep ( Duration :: from_millis ( 100 ) ) . await ;
1246+ }
1247+ Err ( e) => {
1248+ error ! ( "Failed to send data: {}" , e) ;
1249+ return ;
1250+ }
1251+ }
12391252 }
1240- debug ! ( "Sent {} bytes: {}" , data. len( ) , hex:: encode( & data) ) ;
12411253 }
12421254 info ! ( "Send thread finished." ) ;
12431255}
You can’t perform that action at this time.
0 commit comments