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

Function sockpair

lightningd/peer_control.c:59–76  ·  view source on GitHub ↗

Common pattern: create a sockpair for this channel, return one as a peer_fd */

Source from the content-addressed store, hash-verified

57
58/* Common pattern: create a sockpair for this channel, return one as a peer_fd */
59struct peer_fd *sockpair(const tal_t *ctx, struct channel *channel,
60 int *otherfd, const u8 **warning)
61{
62 int fds[2];
63
64 if (socketpair(AF_LOCAL, SOCK_STREAM, 0, fds) != 0) {
65 /* Note: preserves errno! */
66 log_broken(channel->log,
67 "Failed to create socketpair: %s",
68 strerror(errno));
69 if (warning)
70 *warning = towire_warningfmt(ctx, &channel->cid,
71 "Trouble in paradise?");
72 return NULL;
73 }
74 *otherfd = fds[1];
75 return new_peer_fd(ctx, fds[0]);
76}
77
78static void destroy_peer(struct peer *peer)
79{

Callers 4

restart_dualopendFunction · 0.85
connect_activate_subdFunction · 0.85
handle_peer_spokeFunction · 0.85
handle_splice_abortFunction · 0.85

Calls 2

new_peer_fdFunction · 0.70
towire_warningfmtFunction · 0.50

Tested by

no test coverage detected