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

Function new_subd

lightningd/subd.c:708–794  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

706}
707
708static struct subd *new_subd(const tal_t *ctx,
709 struct lightningd *ld,
710 const char *name,
711 void *channel,
712 const struct node_id *node_id,
713 struct logger *base_log,
714 bool talks_to_peer,
715 const char *(*msgname)(int msgtype),
716 unsigned int (*msgcb)(struct subd *,
717 const u8 *, const int *fds),
718 void (*errcb)(void *channel,
719 struct peer_fd *peer_fd,
720 const char *desc,
721 const u8 *err_for_them,
722 bool disconnect,
723 bool warning),
724 void (*billboardcb)(void *channel,
725 bool perm,
726 const char *happenings),
727 va_list *ap)
728{
729 struct subd *sd = tal(ctx, struct subd);
730 int msg_fd;
731 const char *shortname;
732
733 assert(name != NULL);
734
735 /* This part of the name is a bit redundant for logging */
736 if (strstarts(name, "lightning_"))
737 shortname = name + strlen("lightning_");
738 else
739 shortname = name;
740
741 if (base_log) {
742 sd->log = new_logger(sd, ld->log_book, node_id,
743 "%s-%s", shortname, log_prefix(base_log));
744 } else {
745 sd->log = new_logger(sd, ld->log_book, node_id, "%s", shortname);
746 }
747
748 const char *path = subdaemon_path(tmpctx, ld, name);
749
750 sd->pid = subd(path, name, debugging(ld, name),
751 &msg_fd,
752 /* We only turn on subdaemon io/trace logging if we're going
753 * to print it: too stressful otherwise! */
754 log_has_io_logging(sd->log),
755 log_has_trace_logging(sd->log),
756 ld->developer,
757 ap);
758 if (sd->pid == (pid_t)-1) {
759 log_unusual(ld->log, "subd %s failed: %s",
760 name, strerror(errno));
761 return tal_free(sd);
762 }
763 sd->ld = ld;
764
765 sd->name = shortname;

Callers 2

new_global_subdFunction · 0.70
new_channel_subd_Function · 0.70

Calls 10

tal_freeFunction · 0.85
msg_queue_newFunction · 0.85
list_head_initFunction · 0.85
new_loggerFunction · 0.70
log_prefixFunction · 0.70
subdaemon_pathFunction · 0.70
subdFunction · 0.70
debuggingFunction · 0.70
log_has_io_loggingFunction · 0.70
log_has_trace_loggingFunction · 0.70

Tested by

no test coverage detected