This queues other traffic from the fd until we get reply. */
| 966 | |
| 967 | /* This queues other traffic from the fd until we get reply. */ |
| 968 | static u8 *master_wait_sync_reply(const tal_t *ctx, |
| 969 | struct peer *peer, |
| 970 | const u8 *msg, |
| 971 | int replytype) |
| 972 | { |
| 973 | u8 *reply; |
| 974 | |
| 975 | status_debug("Sending master %u", fromwire_peektype(msg)); |
| 976 | |
| 977 | if (!wire_sync_write(MASTER_FD, msg)) |
| 978 | status_failed(STATUS_FAIL_INTERNAL_ERROR, |
| 979 | "Could not set sync write to master: %s", |
| 980 | strerror(errno)); |
| 981 | |
| 982 | status_debug("... , awaiting %u", replytype); |
| 983 | |
| 984 | for (;;) { |
| 985 | int type; |
| 986 | |
| 987 | reply = wire_sync_read(ctx, MASTER_FD); |
| 988 | if (!reply) |
| 989 | status_failed(STATUS_FAIL_INTERNAL_ERROR, |
| 990 | "Could not set sync read from master: %s", |
| 991 | strerror(errno)); |
| 992 | type = fromwire_peektype(reply); |
| 993 | if (type == replytype) { |
| 994 | status_debug("Got it!"); |
| 995 | break; |
| 996 | } |
| 997 | |
| 998 | status_debug("Nope, got %u instead", type); |
| 999 | msg_enqueue(peer->from_master, take(reply)); |
| 1000 | } |
| 1001 | |
| 1002 | return reply; |
| 1003 | } |
| 1004 | |
| 1005 | /* Collect the htlcs for call to hsmd. */ |
| 1006 | static struct simple_htlc **collect_htlcs(const tal_t *ctx, const struct htlc **htlc_map) |
no test coverage detected