Free the holding cells during background timer ticks
authorMatt Corallo <git@bluematt.me>
Mon, 21 Nov 2022 01:22:51 +0000 (01:22 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 6 Dec 2022 18:18:26 +0000 (18:18 +0000)
We currently free the channel holding cells in
`get_and_clear_pending_msg_events`, blocking outbound messages
while we do so. This is fine, but may block the message pipeline
longer than we need to. In the next commit we'll push
timer-originating channel fee updates out through the holding cell
pipeline, leaning more on that freeing in the future.

Thus, to avoid a regression in message time, here we clear the
holding cell after processing all timer events. This also avoids
needing to change tests in the next commit.

lightning/src/ln/channelmanager.rs

index fdd0bb202417ba5f62d1a339bb001633db9ade68..d01ff8b1921cc53ce0e0f3f64864441cc5f13790 100644 (file)
@@ -3817,6 +3817,13 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
 
                        self.remove_stale_resolved_payments();
 
+                       // Technically we don't need to do this here, but if we have holding cell entries in a
+                       // channel that need freeing, it's better to do that here and block a background task
+                       // than block the message queueing pipeline.
+                       if self.check_free_holding_cells() {
+                               should_persist = NotifyOption::DoPersist;
+                       }
+
                        should_persist
                });
        }