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

Function sd_msg_reply

lightningd/subd.c:316–353  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

sd_msg_readFunction · 0.85

Calls 2

fromwire_peektypeFunction · 0.85
io_closeFunction · 0.85

Tested by

no test coverage detected