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

Function daemon_conn_sync_flush

common/daemon_conn.c:93–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91}
92
93bool daemon_conn_sync_flush(struct daemon_conn *dc)
94{
95 const u8 *msg;
96 int daemon_fd;
97
98 /* Flush any current packet. */
99 if (!io_flush_sync(dc->conn))
100 return false;
101
102 /* Make fd blocking for the duration */
103 daemon_fd = io_conn_fd(dc->conn);
104 if (!io_fd_block(daemon_fd, true))
105 return false;
106
107 /* Flush existing messages. */
108 while ((msg = msg_dequeue(dc->out)) != NULL) {
109 int fd = msg_extract_fd(dc->out, msg);
110 if (fd >= 0) {
111 tal_free(msg);
112 if (!fdpass_send(daemon_fd, fd))
113 break;
114 } else if (!wire_sync_write(daemon_fd, take(msg)))
115 break;
116 }
117 io_fd_block(daemon_fd, false);
118
119 /* Success if and only if we flushed them all. */
120 return msg == NULL;
121}
122
123static struct io_plan *daemon_conn_start(struct io_conn *conn,
124 struct daemon_conn *dc)

Callers 1

flush_and_exitFunction · 0.85

Calls 8

io_flush_syncFunction · 0.85
io_conn_fdFunction · 0.85
io_fd_blockFunction · 0.85
msg_dequeueFunction · 0.85
msg_extract_fdFunction · 0.85
tal_freeFunction · 0.85
fdpass_sendFunction · 0.85
wire_sync_writeFunction · 0.50

Tested by

no test coverage detected