Browse Source

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 <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
parent
commit
0cab9d1dd1
  1. 6
      common/daemon_conn.c
  2. 10
      common/daemon_conn.h

6
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);

10
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
*/

Loading…
Cancel
Save