MCPcopy Create free account
hub / github.com/ElementsProject/lightning / write_to_subd

Function write_to_subd

connectd/multiplex.c:1421–1455  ·  view source on GitHub ↗

These four function handle peer->subd */

Source from the content-addressed store, hash-verified

1419
1420/* These four function handle peer->subd */
1421static 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
1457static void destroy_connected_subd(struct subd *subd)
1458{

Callers 1

subd_conn_initFunction · 0.85

Calls 6

msg_dequeueFunction · 0.85
io_closeFunction · 0.85
io_wakeFunction · 0.85
time_to_msecFunction · 0.85
timemono_betweenFunction · 0.85
time_monoFunction · 0.85

Tested by

no test coverage detected