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

Function destroy_io_conn

connectd/connectd.c:951–972  ·  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

949 * it set up by either the creatively-named tal_add_destructor2(), or by
950 * the ccan/io's io_set_finish() on a connection. */
951static void destroy_io_conn(struct io_conn *conn, struct connecting *connect)
952{
953 /*~ tal_append_fmt appends to a tal string. It's terribly convenient */
954 const char *errstr = strerror(errno);
955 /* errno 0 means they hung up on us. */
956 if (errno == 0) {
957 errstr = "peer closed connection";
958 if (streq(connect->connstate, "Cryptographic handshake"))
959 errstr = "peer closed connection (wrong key?)";
960 } else if (errno == EMFILE) {
961 errstr = "Terminated due to too many connections";
962 }
963
964 add_errors_to_error_list(connect,
965 tal_fmt(tmpctx, "%s: %s: %s",
966 fmt_wireaddr_internal(tmpctx,
967 &connect->addrs[connect->addrnum]),
968 connect->connstate, errstr));
969 connect->addrnum++;
970 connect->conn = NULL;
971 try_connect_one_addr(connect);
972}
973
974/* This initializes a fresh io_conn by setting it to io_connect to the
975 * destination */

Callers

nothing calls this directly

Calls 3

add_errors_to_error_listFunction · 0.85
fmt_wireaddr_internalFunction · 0.85
try_connect_one_addrFunction · 0.85

Tested by

no test coverage detected