File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -977,8 +977,21 @@ impl Server {
977977 // this method is used as a select! branch, use while loop to write the data
978978 // instead of using write_all (which is not cancellation safe) to ensure
979979 // the code cancellation safe
980+ let mut wait_count = 0 ;
981+ let mut writen_count = 0 ;
980982 let mut written_bytes = 0 ;
981983 while written_bytes < n {
984+ if writen_count >= 10 {
985+ if wait_count < 3 {
986+ wait_count += 1 ;
987+ tokio:: time:: sleep ( Duration :: from_millis ( 2 ) ) . await ;
988+ } else {
989+ error ! ( "failed to write after having tried {writen_count} times, written {written_bytes}/{n}" ) ;
990+ return Err ( ProxyError :: InternalError ) ;
991+ }
992+ }
993+
994+ writen_count += 1 ;
982995 written_bytes +=
983996 writer. write ( & buffer[ written_bytes..n] ) . await . map_err ( |e| {
984997 error ! ( "write failed: {e}" ) ;
You can’t perform that action at this time.
0 commit comments