Skip to content

Commit aae2a0b

Browse files
rustyrussellsangbida
authored andcommitted
connectd: add "use_uniform_writes" per-peer helper.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent d2d4002 commit aae2a0b

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

connectd/multiplex.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -481,14 +481,18 @@ static bool have_empty_encrypted_queue(const struct peer *peer)
481481
return membuf_num_elems(&peer->encrypted_peer_out) == 0;
482482
}
483483

484+
static bool use_uniform_writes(const struct peer *peer)
485+
{
486+
return peer->daemon->dev_uniform_padding;
487+
}
488+
484489
/* (Continue) writing the encrypted_peer_out array */
485490
static struct io_plan *write_encrypted_to_peer(struct peer *peer)
486491
{
487492
size_t avail = membuf_num_elems(&peer->encrypted_peer_out);
488493
/* With padding: always a full uniform-size chunk.
489494
* Without: flush whatever we have (caller ensures non-zero). */
490-
size_t write_size = peer->daemon->dev_uniform_padding
491-
? UNIFORM_MESSAGE_SIZE : avail;
495+
size_t write_size = use_uniform_writes(peer) ? UNIFORM_MESSAGE_SIZE : avail;
492496

493497
assert(avail >= write_size && write_size > 0);
494498
return io_write_partial(peer->to_peer,
@@ -1250,8 +1254,8 @@ static struct io_plan *write_to_peer(struct io_conn *peer_conn,
12501254
/* Wait for them to wake us */
12511255
return msg_queue_wait(peer_conn, peer->peer_outq, write_to_peer, peer);
12521256
}
1253-
/* OK, add padding (only if --dev-uniform-padding enabled). */
1254-
if (peer->daemon->dev_uniform_padding)
1257+
/* OK, add padding (only if supported). */
1258+
if (use_uniform_writes(peer))
12551259
pad_encrypted_queue(peer);
12561260
else
12571261
break;

0 commit comments

Comments
 (0)