channel: don't send disable update to gossipd if we haven't announced channel yet.

Valgrind error file: /tmp/lightning-8k06jbb3/test_disconnect/lightning-7/valgrind-errors
==32307== Uninitialised byte(s) found during client check request
==32307==    at 0x11EBAD: memcheck_ (mem.h:247)
==32307==    by 0x11EC18: towire (towire.c:14)
==32307==    by 0x11EF19: towire_short_channel_id (towire.c:92)
==32307==    by 0x12203E: towire_channel_update (gen_peer_wire.c:918)
==32307==    by 0x1148D4: send_channel_update (channel.c:185)
==32307==    by 0x1175C5: peer_conn_broken (channel.c:1010)
==32307==    by 0x13186F: destroy_conn (poll.c:173)
==32307==    by 0x13188F: destroy_conn_close_fd (poll.c:179)
==32307==    by 0x13B279: notify (tal.c:235)
==32307==    by 0x13B721: del_tree (tal.c:395)
==32307==    by 0x13BB3A: tal_free (tal.c:504)
==32307==    by 0x130522: io_close (io.c:415)
==32307==  Address 0xffefff87d is on thread 1's stack
==32307==  in frame #2, created by towire_short_channel_id (towire.c:88)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2017-05-24 19:40:06 +09:30
parent 302ed0ca3b
commit 8f190c673c

View File

@ -1007,9 +1007,13 @@ static struct io_plan *setup_peer_conn(struct io_conn *conn, struct peer *peer)
static void peer_conn_broken(struct io_conn *conn, struct peer *peer)
{
send_channel_update(peer, true);
/* Make sure gossipd actually gets this message before dying */
daemon_conn_sync_flush(&peer->gossip_client);
/* If we have signatures, send an update to say we're disabled. */
if (peer->have_sigs[LOCAL] && peer->have_sigs[REMOTE]) {
send_channel_update(peer, true);
/* Make sure gossipd actually gets this message before dying */
daemon_conn_sync_flush(&peer->gossip_client);
}
status_failed(WIRE_CHANNEL_PEER_READ_FAILED,
"peer connection broken: %s", strerror(errno));
}