MCPcopy Create free account
hub / github.com/ElementsProject/lightning / sd_msg_reply

Function sd_msg_reply

lightningd/subd.c:310–347  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

308}
309
310static struct io_plan *sd_msg_reply(struct io_conn *conn, struct subd *sd,
311 struct subd_req *sr)
312{
313 int type = fromwire_peektype(sd->msg_in);
314 bool freed = false;
315 int *fds_in;
316
317 log_debug(sd->log, "REPLY %s with %zu fds",
318 sd->msgname(type), tal_count(sd->fds_in));
319
320 /* Callback could free sd! Make sure destroy_subd() won't free conn */
321 sd->conn = NULL;
322
323 /* We want to free the msg_in, unless they tal_steal() it. */
324 tal_steal(tmpctx, sd->msg_in);
325
326 /* And we need to free sr after this too. */
327 tal_steal(tmpctx, sr);
328 /* In case they free sd, don't deref. */
329 list_del_init(&sr->list);
330
331 /* Free this array after, too. */
332 fds_in = tal_steal(tmpctx, sd->fds_in);
333 sd->fds_in = NULL;
334
335 /* Find out if they freed it. */
336 tal_add_destructor2(sd, mark_freed, &freed);
337 sr->replycb(sd, sd->msg_in, fds_in, sr->replycb_data);
338
339 if (freed)
340 return io_close(conn);
341
342 tal_del_destructor2(sd, mark_freed, &freed);
343
344 /* Restore conn ptr. */
345 sd->conn = conn;
346 return io_read_wire(conn, sd, &sd->msg_in, sd_msg_read, sd);
347}
348
349static struct io_plan *read_fds(struct io_conn *conn, struct subd *sd)
350{

Callers 1

sd_msg_readFunction · 0.85

Calls 2

io_closeFunction · 0.85
fromwire_peektypeFunction · 0.50

Tested by

no test coverage detected