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

Function sockpair

lightningd/peer_control.c:52–69  ·  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

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

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