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

Function destroy_peer_conn

connectd/multiplex.c:1623–1650  ·  view source on GitHub ↗

Peer disconnected (we remove this if *we* close). */

Source from the content-addressed store, hash-verified

1621
1622/* Peer disconnected (we remove this if *we* close). */
1623static void destroy_peer_conn(struct io_conn *peer_conn, struct peer *peer)
1624{
1625 assert(peer->to_peer == peer_conn);
1626
1627 /* We are no longer connected. Tell lightningd & gossipd */
1628 peer->to_peer = NULL;
1629 send_disconnected(peer->daemon, &peer->id, peer->counter,
1630 peer->connect_starttime);
1631
1632 /* Wake subds: give them 5 seconds to flush. */
1633 for (size_t i = 0; i < tal_count(peer->subds); i++) {
1634 /* Might not be connected yet (no destructor, simple) */
1635 if (!peer->subds[i]->conn) {
1636 tal_arr_remove(&peer->subds, i);
1637 i--;
1638 continue;
1639 }
1640 /* Wake the writers to subd: you have 5 seconds */
1641 notleak(new_reltimer(&peer->daemon->timers,
1642 peer->subds[i], time_from_sec(5),
1643 close_subd_timeout, peer->subds[i]));
1644 io_wake(peer->subds[i]->outq);
1645 }
1646
1647 /* If there were no subds, free peer immediately. */
1648 if (tal_count(peer->subds) == 0)
1649 tal_free(peer);
1650}
1651
1652/* When peer reconnects, we close the old connection unceremoniously. */
1653void destroy_peer_immediately(struct peer *peer)

Callers

nothing calls this directly

Calls 4

send_disconnectedFunction · 0.85
time_from_secFunction · 0.85
io_wakeFunction · 0.85
tal_freeFunction · 0.85

Tested by

no test coverage detected