Skip to content

Commit 8aa00df

Browse files
committed
f update net-tokio to new semantics and simplify a bit
1 parent de27ddf commit 8aa00df

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

lightning-net-tokio/src/lib.rs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ impl SocketDescriptor {
528528
}
529529
}
530530
impl peer_handler::SocketDescriptor for SocketDescriptor {
531-
fn send_data(&mut self, data: &[u8], resume_read: bool) -> usize {
531+
fn send_data(&mut self, data: &[u8], continue_read: bool) -> usize {
532532
// To send data, we take a lock on our Connection to access the TcpStream, writing to it if
533533
// there's room in the kernel buffer, or otherwise create a new Waker with a
534534
// SocketDescriptor in it which can wake up the write_avail Sender, waking up the
@@ -539,14 +539,14 @@ impl peer_handler::SocketDescriptor for SocketDescriptor {
539539
return 0;
540540
}
541541

542-
if resume_read && us.read_paused {
542+
let read_was_paused = us.read_paused;
543+
us.read_paused = !continue_read;
544+
545+
if continue_read && read_was_paused {
543546
// The schedule_read future may go to lock up but end up getting woken up by there
544547
// being more room in the write buffer, dropping the other end of this Sender
545548
// before we get here, so we ignore any failures to wake it up.
546-
us.read_paused = false;
547549
let _ = us.read_waker.try_send(());
548-
} else if !resume_read {
549-
us.read_paused = true;
550550
}
551551

552552
if data.is_empty() {
@@ -574,16 +574,7 @@ impl peer_handler::SocketDescriptor for SocketDescriptor {
574574
}
575575
},
576576
task::Poll::Ready(Err(_)) => return written_len,
577-
task::Poll::Pending => {
578-
// We're queued up for a write event now, but we need to make sure we also
579-
// pause read given we're now waiting on the remote end to ACK (and in
580-
// accordance with the send_data() docs).
581-
us.read_paused = true;
582-
// Further, to avoid any current pending read causing a `read_event` call, wake
583-
// up the read_waker and restart its loop.
584-
let _ = us.read_waker.try_send(());
585-
return written_len;
586-
},
577+
task::Poll::Pending => return written_len,
587578
}
588579
}
589580
}

0 commit comments

Comments
 (0)