| 1455 | } |
| 1456 | |
| 1457 | static void destroy_connected_subd(struct subd *subd) |
| 1458 | { |
| 1459 | struct peer *peer = subd->peer; |
| 1460 | size_t pos; |
| 1461 | |
| 1462 | for (pos = 0; peer->subds[pos] != subd; pos++) |
| 1463 | assert(pos < tal_count(peer->subds)); |
| 1464 | |
| 1465 | tal_arr_remove(&peer->subds, pos); |
| 1466 | |
| 1467 | /* Make sure we try to keep reading from peer (might |
| 1468 | * have been waiting for write_to_subd) */ |
| 1469 | io_wake(&peer->peer_in); |
| 1470 | |
| 1471 | if (tal_count(peer->subds) == 0) { |
| 1472 | if (!peer->to_peer) { |
| 1473 | /* Nothing left */ |
| 1474 | tal_free(peer); |
| 1475 | } else if (peer->draining_state == READING_FROM_SUBDS) { |
| 1476 | /* We've finished draining subds, start draining peer */ |
| 1477 | drain_peer(peer); |
| 1478 | } |
| 1479 | } |
| 1480 | } |
| 1481 | |
| 1482 | static struct subd *new_subd(struct peer *peer, |
| 1483 | const struct channel_id *channel_id) |
nothing calls this directly
no test coverage detected