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

Function destroy_io_conn

connectd/connectd.c:659–678  ·  view source on GitHub ↗

~ This is the destructor for the (unsuccessful) outgoing connection. We accumulate * the errors which occurred, so we can report to lightningd properly in case * they all fail, and try the next address. * * This is a specialized form of destructor which takes an extra argument; * it set up by either the creatively-named tal_add_destructor2(), or by * the ccan/io's io_set_finish() on a conne

Source from the content-addressed store, hash-verified

657 * it set up by either the creatively-named tal_add_destructor2(), or by
658 * the ccan/io's io_set_finish() on a connection. */
659static void destroy_io_conn(struct io_conn *conn, struct connecting *connect)
660{
661 /*~ tal_append_fmt appends to a tal string. It's terribly convenient */
662 const char *errstr = strerror(errno);
663 /* errno 0 means they hung up on us. */
664 if (errno == 0) {
665 errstr = "peer closed connection";
666 if (streq(connect->connstate, "Cryptographic handshake"))
667 errstr = "peer closed connection (wrong key?)";
668 }
669
670 add_errors_to_error_list(connect,
671 tal_fmt(tmpctx, "%s: %s: %s",
672 type_to_string(tmpctx, struct wireaddr_internal,
673 &connect->addrs[connect->addrnum]),
674 connect->connstate, errstr));
675 connect->addrnum++;
676 connect->conn = NULL;
677 try_connect_one_addr(connect);
678}
679
680/* This initializes a fresh io_conn by setting it to io_connect to the
681 * destination */

Callers

nothing calls this directly

Calls 3

add_errors_to_error_listFunction · 0.85
try_connect_one_addrFunction · 0.85
type_to_stringClass · 0.50

Tested by

no test coverage detected