@@ -499,7 +499,7 @@ impl SocketDescriptor {
499499 }
500500}
501501impl peer_handler:: SocketDescriptor for SocketDescriptor {
502- fn send_data ( & mut self , data : & [ u8 ] , resume_read : bool ) -> usize {
502+ fn send_data ( & mut self , data : & [ u8 ] , continue_read : bool ) -> usize {
503503 // To send data, we take a lock on our Connection to access the TcpStream, writing to it if
504504 // there's room in the kernel buffer, or otherwise create a new Waker with a
505505 // SocketDescriptor in it which can wake up the write_avail Sender, waking up the
@@ -510,14 +510,14 @@ impl peer_handler::SocketDescriptor for SocketDescriptor {
510510 return 0 ;
511511 }
512512
513- if resume_read && us. read_paused {
513+ let read_was_paused = us. read_paused ;
514+ us. read_paused = !continue_read;
515+
516+ if continue_read && read_was_paused {
514517 // The schedule_read future may go to lock up but end up getting woken up by there
515518 // being more room in the write buffer, dropping the other end of this Sender
516519 // before we get here, so we ignore any failures to wake it up.
517- us. read_paused = false ;
518520 let _ = us. read_waker . try_send ( ( ) ) ;
519- } else if !resume_read {
520- us. read_paused = true ;
521521 }
522522
523523 if data. is_empty ( ) {
@@ -545,16 +545,7 @@ impl peer_handler::SocketDescriptor for SocketDescriptor {
545545 }
546546 } ,
547547 task:: Poll :: Ready ( Err ( _) ) => return written_len,
548- task:: Poll :: Pending => {
549- // We're queued up for a write event now, but we need to make sure we also
550- // pause read given we're now waiting on the remote end to ACK (and in
551- // accordance with the send_data() docs).
552- us. read_paused = true ;
553- // Further, to avoid any current pending read causing a `read_event` call, wake
554- // up the read_waker and restart its loop.
555- let _ = us. read_waker . try_send ( ( ) ) ;
556- return written_len;
557- } ,
548+ task:: Poll :: Pending => return written_len,
558549 }
559550 }
560551 }
0 commit comments