Skip to content

Commit 309d453

Browse files
committed
channeld: allow outgoing messages through even if they have send STFU.
Otherwise, we can hang: we don't send commitment_signed, and they're waiting to receive it. 1. We defer fee updates, blockheight updates and master requests (adding and closing htlcs) if we're *trying* or *started* to quiesce. 2. We only stop actually sending commitment_signed if we have sent STFU. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-EXPERIMENTAL: Protocol: avoid an occasional hang when splicing with a pending closing HTLC.
1 parent 35e6dc6 commit 309d453

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

channeld/channeld.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,18 @@ const u8 *hsm_req(const tal_t *ctx, const u8 *req TAKES)
214214
return msg;
215215
}
216216

217+
/* We're in STFU mode now: must not send messages. */
217218
static bool is_stfu_active(const struct peer *peer)
218219
{
219220
return peer->stfu_sent[LOCAL] && peer->stfu_sent[REMOTE];
220221
}
221222

223+
/* We're trying to enter STFU mode now: don't start *new* conversations */
224+
static bool is_entering_stfu(const struct peer *peer)
225+
{
226+
return peer->want_stfu || peer->stfu_sent[LOCAL] || peer->stfu_sent[REMOTE];
227+
}
228+
222229
static void end_stfu_mode(struct peer *peer)
223230
{
224231
peer->want_stfu = false;
@@ -353,7 +360,7 @@ static void handle_stfu(struct peer *peer, const u8 *stfu)
353360
/* Returns true if we queued this for later handling (steals if true) */
354361
static bool handle_master_request_later(struct peer *peer, const u8 *msg)
355362
{
356-
if (is_stfu_active(peer)) {
363+
if (is_entering_stfu(peer)) {
357364
msg_enqueue(peer->update_queue, take(msg));
358365
return true;
359366
}
@@ -1087,7 +1094,7 @@ static bool want_fee_update(const struct peer *peer, u32 *target)
10871094
return false;
10881095

10891096
/* No fee update while quiescing! */
1090-
if (peer->want_stfu || is_stfu_active(peer))
1097+
if (is_entering_stfu(peer))
10911098
return false;
10921099

10931100
current = channel_feerate(peer->channel, REMOTE);
@@ -1125,8 +1132,8 @@ static bool want_blockheight_update(const struct peer *peer, u32 *height)
11251132
if (peer->channel->lease_expiry == 0)
11261133
return false;
11271134

1128-
/* No fee update while quiescing! */
1129-
if (peer->want_stfu || is_stfu_active(peer))
1135+
/* No block update while quiescing! */
1136+
if (is_entering_stfu(peer))
11301137
return false;
11311138

11321139
/* What's the current blockheight */
@@ -1509,10 +1516,9 @@ static void send_commit(struct peer *peer)
15091516

15101517
static void send_commit_if_not_stfu(struct peer *peer)
15111518
{
1512-
if (!is_stfu_active(peer) && !peer->want_stfu) {
1519+
if (!peer->stfu_sent[LOCAL]) {
15131520
send_commit(peer);
1514-
}
1515-
else {
1521+
} else {
15161522
/* Timer now considered expired, you can add a new one. */
15171523
peer->commit_timer = NULL;
15181524
start_commit_timer(peer);

0 commit comments

Comments
 (0)