From 0cab9d1dd11a396ec889957eaccfb5293a2a6d55 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 6 Dec 2017 16:43:56 +1030 Subject: [PATCH] daemon_conn: helper to release daemon_conn. We'll want this for the next change, where gossipd migrates remote peers back to local ones. Signed-off-by: Rusty Russell --- common/daemon_conn.c | 6 ++++++ common/daemon_conn.h | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/common/daemon_conn.c b/common/daemon_conn.c index 899a497e8..0928b84b6 100644 --- a/common/daemon_conn.c +++ b/common/daemon_conn.c @@ -87,6 +87,12 @@ void daemon_conn_init(tal_t *ctx, struct daemon_conn *dc, int fd, io_set_finish(conn, finish, dc); } +void daemon_conn_clear(struct daemon_conn *dc) +{ + io_set_finish(dc->conn, NULL, NULL); + io_close(dc->conn); +} + void daemon_conn_send(struct daemon_conn *dc, const u8 *msg) { msg_enqueue(&dc->out, msg); diff --git a/common/daemon_conn.h b/common/daemon_conn.h index 456b1af67..fec23720c 100644 --- a/common/daemon_conn.h +++ b/common/daemon_conn.h @@ -43,6 +43,16 @@ void daemon_conn_init(tal_t *ctx, struct daemon_conn *dc, int fd, struct io_plan *(*daemon_conn_recv)( struct io_conn *, struct daemon_conn *), void (*finish)(struct io_conn *, struct daemon_conn *)); + +/** + * daemon_conn_clear - discard a daemon conn without triggering finish. + * @dc: the daemon_conn to clean up. + * + * This is used by gossipd when a peer is handed back, and we no longer + * want to deal with it via daemon_conn. @dc must not be used after this! + */ +void daemon_conn_clear(struct daemon_conn *dc); + /** * daemon_conn_send - Enqueue an outgoing message to be sent */