| 1359 | } |
| 1360 | |
| 1361 | static void destroy_connected_subd(struct subd *subd) |
| 1362 | { |
| 1363 | struct peer *peer = subd->peer; |
| 1364 | size_t pos; |
| 1365 | |
| 1366 | for (pos = 0; peer->subds[pos] != subd; pos++) |
| 1367 | assert(pos < tal_count(peer->subds)); |
| 1368 | |
| 1369 | tal_arr_remove(&peer->subds, pos); |
| 1370 | |
| 1371 | /* Make sure we try to keep reading from peer (might |
| 1372 | * have been waiting for write_to_subd) */ |
| 1373 | io_wake(&peer->peer_in); |
| 1374 | |
| 1375 | if (tal_count(peer->subds) == 0) { |
| 1376 | if (!peer->to_peer) { |
| 1377 | /* Nothing left */ |
| 1378 | tal_free(peer); |
| 1379 | } else if (peer->draining_state == READING_FROM_SUBDS) { |
| 1380 | /* We've finished draining subds, start draining peer */ |
| 1381 | drain_peer(peer); |
| 1382 | } |
| 1383 | } |
| 1384 | } |
| 1385 | |
| 1386 | static struct subd *new_subd(struct peer *peer, |
| 1387 | const struct channel_id *channel_id) |
nothing calls this directly
no test coverage detected