| 51 | } |
| 52 | |
| 53 | static 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 | |
| 79 | struct io_plan *io_read_wire_(struct io_conn *conn, |
| 80 | const tal_t *ctx, |
nothing calls this directly
no test coverage detected