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

Function do_read_wire

wire/wire_io.c:53–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51}
52
53static int do_read_wire(int fd, struct io_plan_arg *arg)
54{
55 ssize_t ret;
56
57 /* Still reading header? */
58 if (arg->u2.s & INSIDE_HEADER_BIT) {
59 ret = do_read_wire_header(fd, arg);
60 /* If this is OK, and finished header, we continue below. */
61 if (ret != 0 || (arg->u2.s & INSIDE_HEADER_BIT))
62 return ret;
63 }
64
65 /* Normal read */
66 ret = read(fd, arg->u1.cp, arg->u2.s);
67 if (ret <= 0) {
68 /* Errno isn't set if we hit EOF, so set it to distinct value */
69 if (ret == 0)
70 errno = 0;
71 return -1;
72 }
73
74 arg->u1.cp += ret;
75 arg->u2.s -= ret;
76 return arg->u2.s == 0;
77}
78
79struct io_plan *io_read_wire_(struct io_conn *conn,
80 const tal_t *ctx,

Callers

nothing calls this directly

Calls 1

do_read_wire_headerFunction · 0.85

Tested by

no test coverage detected