diff --git a/lightningd/gossip_control.c b/lightningd/gossip_control.c index 069691c8b..5c0a13403 100644 --- a/lightningd/gossip_control.c +++ b/lightningd/gossip_control.c @@ -136,7 +136,7 @@ void gossip_init(struct lightningd *ld) { tal_t *tmpctx = tal_tmpctx(ld); u8 *init; - ld->gossip = new_subd(ld, ld, "lightning_gossipd", NULL, + ld->gossip = new_subd(ld, "lightning_gossipd", NULL, gossip_wire_type_name, gossip_msg, NULL, gossip_finished, NULL); if (!ld->gossip) diff --git a/lightningd/new_connection.c b/lightningd/new_connection.c index 5cb79f860..39fa22d0f 100644 --- a/lightningd/new_connection.c +++ b/lightningd/new_connection.c @@ -220,7 +220,7 @@ static struct io_plan *hsm_then_handshake(struct io_conn *conn, io_fd_block(connfd, true); /* Give handshake daemon the hsm fd. */ - handshaked = new_subd(ld, ld, + handshaked = new_subd(ld, "lightning_handshaked", NULL, handshake_wire_type_name, NULL, NULL, NULL, diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index 68f4a36ee..1da45f501 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -1396,7 +1396,7 @@ static enum watch_result funding_spent(struct peer *peer, /* We could come from almost any state. */ peer_set_condition(peer, peer->state, FUNDING_SPEND_SEEN); - peer->owner = new_subd(peer->ld, peer->ld, + peer->owner = new_subd(peer->ld, "lightning_onchaind", peer, onchain_wire_type_name, onchain_msg, @@ -1950,7 +1950,7 @@ static void peer_start_closingd(struct peer *peer, return; } - peer->owner = new_subd(peer->ld, peer->ld, + peer->owner = new_subd(peer->ld, "lightning_closingd", peer, closing_wire_type_name, closing_msg, @@ -2126,7 +2126,7 @@ static bool peer_start_channeld(struct peer *peer, if (hsmfd < 0) fatal("Could not read fd from HSM: %s", strerror(errno)); - peer->owner = new_subd(peer->ld, peer->ld, + peer->owner = new_subd(peer->ld, "lightning_channeld", peer, channel_wire_type_name, channel_msg, @@ -2478,7 +2478,7 @@ void peer_fundee_open(struct peer *peer, const u8 *from_peer, } peer_set_condition(peer, GOSSIPD, OPENINGD); - peer->owner = new_subd(ld, ld, "lightning_openingd", peer, + peer->owner = new_subd(ld, "lightning_openingd", peer, opening_wire_type_name, NULL, bad_peer, peer_owner_finished, take(&peer_fd), take(&gossip_fd), @@ -2561,7 +2561,7 @@ static bool gossip_peer_released(struct subd *gossip, assert(tal_count(fds) == 2); peer_set_condition(fc->peer, GOSSIPD, OPENINGD); - opening = new_subd(fc->peer->ld, ld, + opening = new_subd(ld, "lightning_openingd", fc->peer, opening_wire_type_name, NULL, bad_peer, peer_owner_finished, diff --git a/lightningd/subd.c b/lightningd/subd.c index 81e508b53..feac587c7 100644 --- a/lightningd/subd.c +++ b/lightningd/subd.c @@ -504,8 +504,7 @@ static struct io_plan *msg_setup(struct io_conn *conn, struct subd *sd) msg_send_next(conn, sd)); } -struct subd *new_subd(const tal_t *ctx, - struct lightningd *ld, +struct subd *new_subd(struct lightningd *ld, const char *name, struct peer *peer, const char *(*msgname)(int msgtype), @@ -515,7 +514,7 @@ struct subd *new_subd(const tal_t *ctx, ...) { va_list ap; - struct subd *sd = tal(ctx, struct subd); + struct subd *sd = tal(ld, struct subd); int msg_fd; va_start(ap, finished); @@ -541,7 +540,7 @@ struct subd *new_subd(const tal_t *ctx, sd->peer = peer; /* conn actually owns daemon: we die when it does. */ - sd->conn = io_new_conn(ctx, msg_fd, msg_setup, sd); + sd->conn = io_new_conn(ld, msg_fd, msg_setup, sd); tal_steal(sd->conn, sd); log_info(sd->log, "pid %u, msgfd %i", sd->pid, msg_fd); diff --git a/lightningd/subd.h b/lightningd/subd.h index 38813c5fb..f6ab4bb44 100644 --- a/lightningd/subd.h +++ b/lightningd/subd.h @@ -55,7 +55,6 @@ struct subd { /** * new_subd - create a new subdaemon. - * @ctx: context to allocate from * @ld: global state * @name: basename of daemon * @peer: peer to associate (if any). @@ -70,8 +69,7 @@ struct subd { * that many @fds are received before calling again. If it returns -1, the * subdaemon is shutdown. */ -struct subd *new_subd(const tal_t *ctx, - struct lightningd *ld, +struct subd *new_subd(struct lightningd *ld, const char *name, struct peer *peer, const char *(*msgname)(int msgtype),