devtools/gossipwith: allow --max-messages=0 to avoid reading msgs at all.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
a358b9ab57
commit
e40f07803c
|
@ -155,7 +155,7 @@ static struct io_plan *handshake_success(struct io_conn *conn,
|
||||||
args++;
|
args++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (;;) {
|
while (max_messages != 0 || pollfd[0].fd != -1) {
|
||||||
beint16_t belen;
|
beint16_t belen;
|
||||||
u8 *msg;
|
u8 *msg;
|
||||||
|
|
||||||
|
@ -175,17 +175,16 @@ static struct io_plan *handshake_success(struct io_conn *conn,
|
||||||
} else if (pollfd[1].revents & POLLIN) {
|
} else if (pollfd[1].revents & POLLIN) {
|
||||||
msg = sync_crypto_read(NULL, pps);
|
msg = sync_crypto_read(NULL, pps);
|
||||||
if (!msg)
|
if (!msg)
|
||||||
break;
|
err(1, "Reading msg");
|
||||||
belen = cpu_to_be16(tal_bytelen(msg));
|
belen = cpu_to_be16(tal_bytelen(msg));
|
||||||
if (!write_all(STDOUT_FILENO, &belen, sizeof(belen))
|
if (!write_all(STDOUT_FILENO, &belen, sizeof(belen))
|
||||||
|| !write_all(STDOUT_FILENO, msg, tal_bytelen(msg)))
|
|| !write_all(STDOUT_FILENO, msg, tal_bytelen(msg)))
|
||||||
err(1, "Writing out msg");
|
err(1, "Writing out msg");
|
||||||
tal_free(msg);
|
tal_free(msg);
|
||||||
if (--max_messages == 0)
|
--max_messages;
|
||||||
exit(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
err(1, "Reading msg");
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *opt_set_secret(const char *arg, struct secret *s)
|
static char *opt_set_secret(const char *arg, struct secret *s)
|
||||||
|
|
Loading…
Reference in New Issue