File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -602,10 +602,20 @@ pub mod sender {
602602 } ) ) )
603603 } else {
604604 //indicate that the test is over by sending the test ID by itself
605- for _ in 0 ..4 { //do it a few times in case of loss
606- let send_result = self . socket . send ( & self . staged_packet [ 0 ..16 ] ) ;
607- if send_result. is_err ( ) {
608- return Some ( Err ( Box :: new ( send_result. unwrap_err ( ) ) ) ) ;
605+ let mut remaining_announcements = 5 ;
606+ while remaining_announcements > 0 { //do it a few times in case of loss
607+ match self . socket . send ( & self . staged_packet [ 0 ..16 ] ) {
608+ Ok ( packet_size) => {
609+ log:: trace!( "wrote {} bytes of test-end signal in UDP stream {}" , packet_size, self . stream_idx) ;
610+ remaining_announcements -= 1 ;
611+ } ,
612+ Err ( e) if e. kind ( ) == std:: io:: ErrorKind :: WouldBlock => { //send-buffer is full
613+ //wait to try again and avoid burning CPU cycles
614+ sleep ( BUFFER_FULL_TIMEOUT ) ;
615+ } ,
616+ Err ( e) => {
617+ return Some ( Err ( Box :: new ( e) ) ) ;
618+ } ,
609619 }
610620 }
611621 None
You can’t perform that action at this time.
0 commit comments