These four function handle peer->subd */
| 1419 | |
| 1420 | /* These four function handle peer->subd */ |
| 1421 | static struct io_plan *write_to_subd(struct io_conn *subd_conn, |
| 1422 | struct subd *subd) |
| 1423 | { |
| 1424 | const u8 *msg; |
| 1425 | assert(subd->conn == subd_conn); |
| 1426 | |
| 1427 | /* Pop tail of send queue */ |
| 1428 | msg = msg_dequeue(subd->outq); |
| 1429 | |
| 1430 | /* Nothing to send? */ |
| 1431 | if (!msg) { |
| 1432 | /* If peer is closed, close this. */ |
| 1433 | if (!subd->peer->to_peer) |
| 1434 | return io_close(subd_conn); |
| 1435 | |
| 1436 | /* Tell them to read again. */ |
| 1437 | io_wake(&subd->peer->peer_in); |
| 1438 | if (subd->peer->peer_in_lastmsg != -1) { |
| 1439 | u64 msec = time_to_msec(timemono_between(time_mono(), |
| 1440 | subd->peer->peer_in_lasttime)); |
| 1441 | if (msec > 5000 && !subd->peer->daemon->dev_lightningd_is_slow) |
| 1442 | status_peer_broken(&subd->peer->id, |
| 1443 | "wake delay for %s: %"PRIu64"msec", |
| 1444 | peer_wire_name(subd->peer->peer_in_lastmsg), |
| 1445 | msec); |
| 1446 | subd->peer->peer_in_lastmsg = -1; |
| 1447 | } |
| 1448 | |
| 1449 | /* Wait for them to wake us */ |
| 1450 | return msg_queue_wait(subd_conn, subd->outq, |
| 1451 | write_to_subd, subd); |
| 1452 | } |
| 1453 | |
| 1454 | return io_write_wire(subd_conn, take(msg), write_to_subd, subd); |
| 1455 | } |
| 1456 | |
| 1457 | static void destroy_connected_subd(struct subd *subd) |
| 1458 | { |
no test coverage detected