Skip to content

Commit

Permalink
devtools/gossipwith: allow --max-messages=0 to avoid reading msgs at …
Browse files Browse the repository at this point in the history
…all.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Aug 20, 2019
1 parent a358b9a commit e40f078
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions devtools/gossipwith.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ static struct io_plan *handshake_success(struct io_conn *conn,
args++;
}

for (;;) {
while (max_messages != 0 || pollfd[0].fd != -1) {
beint16_t belen;
u8 *msg;

Expand All @@ -175,17 +175,16 @@ static struct io_plan *handshake_success(struct io_conn *conn,
} else if (pollfd[1].revents & POLLIN) {
msg = sync_crypto_read(NULL, pps);
if (!msg)
break;
err(1, "Reading msg");
belen = cpu_to_be16(tal_bytelen(msg));
if (!write_all(STDOUT_FILENO, &belen, sizeof(belen))
|| !write_all(STDOUT_FILENO, msg, tal_bytelen(msg)))
err(1, "Writing out msg");
tal_free(msg);
if (--max_messages == 0)
exit(0);
--max_messages;
}
}
err(1, "Reading msg");
exit(0);
}

static char *opt_set_secret(const char *arg, struct secret *s)
Expand Down

0 comments on commit e40f078

Please sign in to comment.