devtools/gossipwith: don't count "padding" pings towards max-messages count.
We are about to use them to make our packet size constant, and this will upset the tests. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -256,16 +256,22 @@ static struct io_plan *handshake_success(struct io_conn *conn,
|
|||||||
}
|
}
|
||||||
} else if (pollfd[1].revents & POLLIN) {
|
} else if (pollfd[1].revents & POLLIN) {
|
||||||
u8 *pong;
|
u8 *pong;
|
||||||
|
bool is_padding;
|
||||||
|
|
||||||
msg = sync_crypto_read(NULL, peer_fd, cs);
|
msg = sync_crypto_read(NULL, peer_fd, cs);
|
||||||
if (!msg)
|
if (!msg)
|
||||||
err(1, "Reading msg");
|
err(1, "Reading msg");
|
||||||
if (handle_pings
|
if (check_ping_make_pong(tmpctx, msg, &pong)) {
|
||||||
&& fromwire_peektype(msg) == WIRE_PING
|
if (!pong)
|
||||||
&& check_ping_make_pong(tmpctx, msg, &pong)
|
is_padding = true;
|
||||||
&& pong) {
|
else {
|
||||||
sync_crypto_write(peer_fd, cs, take(pong));
|
is_padding = false;
|
||||||
}
|
if (handle_pings)
|
||||||
|
sync_crypto_write(peer_fd, cs, take(pong));
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
is_padding = false;
|
||||||
|
|
||||||
if (!accept_message(msg)) {
|
if (!accept_message(msg)) {
|
||||||
tal_free(msg);
|
tal_free(msg);
|
||||||
continue;
|
continue;
|
||||||
@@ -278,7 +284,9 @@ static struct io_plan *handshake_success(struct io_conn *conn,
|
|||||||
|| !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");
|
||||||
}
|
}
|
||||||
--max_messages;
|
/* Don't count "padding" pings as real messages */
|
||||||
|
if (!is_padding)
|
||||||
|
--max_messages;
|
||||||
tal_free(msg);
|
tal_free(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user