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

Function do_write_wire

wire/wire_io.c:115–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113}
114
115static int do_write_wire(int fd, struct io_plan_arg *arg)
116{
117 ssize_t ret;
118 size_t totlen = tal_bytelen(arg->u1.cp);
119
120 /* Still writing header? */
121 if (arg->u2.s & INSIDE_HEADER_BIT) {
122 ret = do_write_wire_header(fd, arg);
123 /* If this is OK, and finished header, we continue below. */
124 if (ret != 0 || (arg->u2.s & INSIDE_HEADER_BIT))
125 return ret;
126 }
127
128 /* Normal write */
129 ret = write(fd, arg->u1.cp + arg->u2.s, totlen - arg->u2.s);
130 if (ret < 0)
131 return -1;
132
133 arg->u2.s += ret;
134 if (arg->u2.s != totlen)
135 return 0;
136
137 tal_free(arg->u1.cp);
138 return 1;
139}
140
141/* Write message from data (tal_count(data) gives length). */
142struct io_plan *io_write_wire_(struct io_conn *conn,

Callers

nothing calls this directly

Calls 3

tal_bytelenFunction · 0.85
do_write_wire_headerFunction · 0.85
tal_freeFunction · 0.85

Tested by

no test coverage detected