These four function handle peer->subd */
| 1009 | |
| 1010 | /* These four function handle peer->subd */ |
| 1011 | static struct io_plan *write_to_subd(struct io_conn *subd_conn, |
| 1012 | struct subd *subd) |
| 1013 | { |
| 1014 | const u8 *msg; |
| 1015 | assert(subd->conn == subd_conn); |
| 1016 | |
| 1017 | /* Pop tail of send queue */ |
| 1018 | msg = msg_dequeue(subd->outq); |
| 1019 | |
| 1020 | /* Nothing to send? */ |
| 1021 | if (!msg) { |
| 1022 | /* If peer is closed, close this. */ |
| 1023 | if (!subd->peer->to_peer) |
| 1024 | return io_close(subd_conn); |
| 1025 | |
| 1026 | /* Tell them to read again. */ |
| 1027 | io_wake(&subd->peer->peer_in); |
| 1028 | |
| 1029 | /* Wait for them to wake us */ |
| 1030 | return msg_queue_wait(subd_conn, subd->outq, |
| 1031 | write_to_subd, subd); |
| 1032 | } |
| 1033 | |
| 1034 | return io_write_wire(subd_conn, take(msg), write_to_subd, subd); |
| 1035 | } |
| 1036 | |
| 1037 | static void destroy_subd(struct subd *subd) |
| 1038 | { |
no test coverage detected