Peer disconnected (we remove this if *we* close). */
| 1734 | |
| 1735 | /* Peer disconnected (we remove this if *we* close). */ |
| 1736 | static void destroy_peer_conn(struct io_conn *peer_conn, struct peer *peer) |
| 1737 | { |
| 1738 | assert(peer->to_peer == peer_conn); |
| 1739 | |
| 1740 | /* We are no longer connected. Tell lightningd & gossipd */ |
| 1741 | peer->to_peer = NULL; |
| 1742 | send_disconnected(peer->daemon, &peer->id, peer->counter, |
| 1743 | peer->connect_starttime); |
| 1744 | |
| 1745 | /* Wake subds: give them 5 seconds to flush. */ |
| 1746 | for (size_t i = 0; i < tal_count(peer->subds); i++) { |
| 1747 | /* Might not be connected yet (no destructor, simple) */ |
| 1748 | if (!peer->subds[i]->conn) { |
| 1749 | tal_arr_remove(&peer->subds, i); |
| 1750 | i--; |
| 1751 | continue; |
| 1752 | } |
| 1753 | /* Wake the writers to subd: you have 5 seconds */ |
| 1754 | notleak(new_reltimer(&peer->daemon->timers, |
| 1755 | peer->subds[i], time_from_sec(5), |
| 1756 | close_subd_timeout, peer->subds[i])); |
| 1757 | io_wake(peer->subds[i]->outq); |
| 1758 | } |
| 1759 | |
| 1760 | /* If there were no subds, free peer immediately. */ |
| 1761 | if (tal_count(peer->subds) == 0) |
| 1762 | tal_free(peer); |
| 1763 | } |
| 1764 | |
| 1765 | /* When peer reconnects, we close the old connection unceremoniously. */ |
| 1766 | void destroy_peer_immediately(struct peer *peer) |
nothing calls this directly
no test coverage detected