]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Wake reader future when we fail to flush socket buffer
authorMatt Corallo <git@bluematt.me>
Sun, 3 Oct 2021 21:44:52 +0000 (21:44 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 10 May 2022 23:40:20 +0000 (23:40 +0000)
This avoids any extra calls to `read_event` after a write fails to
flush the write buffer fully, as is required by the PeerManager
API (though it isn't critical).

lightning-net-tokio/src/lib.rs

index cee7c5c1b982882244cdb33a5d82d7abb0c8eadc..fc7b260e41bf1c6d54d8df15436cf865f64629ed 100644 (file)
@@ -465,6 +465,9 @@ impl peer_handler::SocketDescriptor for SocketDescriptor {
                                        // pause read given we're now waiting on the remote end to ACK (and in
                                        // accordance with the send_data() docs).
                                        us.read_paused = true;
+                                       // Further, to avoid any current pending read causing a `read_event` call, wake
+                                       // up the read_waker and restart its loop.
+                                       let _ = us.read_waker.try_send(());
                                        return written_len;
                                },
                        }