These four function handle peer->subd */
| 1323 | |
| 1324 | /* These four function handle peer->subd */ |
| 1325 | static struct io_plan *write_to_subd(struct io_conn *subd_conn, |
| 1326 | struct subd *subd) |
| 1327 | { |
| 1328 | const u8 *msg; |
| 1329 | assert(subd->conn == subd_conn); |
| 1330 | |
| 1331 | /* Pop tail of send queue */ |
| 1332 | msg = msg_dequeue(subd->outq); |
| 1333 | |
| 1334 | /* Nothing to send? */ |
| 1335 | if (!msg) { |
| 1336 | /* If peer is closed, close this. */ |
| 1337 | if (!subd->peer->to_peer) |
| 1338 | return io_close(subd_conn); |
| 1339 | |
| 1340 | /* Tell them to read again. */ |
| 1341 | io_wake(&subd->peer->peer_in); |
| 1342 | if (subd->peer->peer_in_lastmsg != -1) { |
| 1343 | u64 msec = time_to_msec(timemono_between(time_mono(), |
| 1344 | subd->peer->peer_in_lasttime)); |
| 1345 | if (msec > 5000 && !subd->peer->daemon->dev_lightningd_is_slow) |
| 1346 | status_peer_broken(&subd->peer->id, |
| 1347 | "wake delay for %s: %"PRIu64"msec", |
| 1348 | peer_wire_name(subd->peer->peer_in_lastmsg), |
| 1349 | msec); |
| 1350 | subd->peer->peer_in_lastmsg = -1; |
| 1351 | } |
| 1352 | |
| 1353 | /* Wait for them to wake us */ |
| 1354 | return msg_queue_wait(subd_conn, subd->outq, |
| 1355 | write_to_subd, subd); |
| 1356 | } |
| 1357 | |
| 1358 | return io_write_wire(subd_conn, take(msg), write_to_subd, subd); |
| 1359 | } |
| 1360 | |
| 1361 | static void destroy_connected_subd(struct subd *subd) |
| 1362 | { |
no test coverage detected