arg->u2.s contains length we've written, arg->u1 contains u8 *data. */
| 95 | |
| 96 | /* arg->u2.s contains length we've written, arg->u1 contains u8 *data. */ |
| 97 | static int do_write_wire_header(int fd, struct io_plan_arg *arg) |
| 98 | { |
| 99 | ssize_t ret; |
| 100 | size_t len = arg->u2.s & ~INSIDE_HEADER_BIT; |
| 101 | wire_len_t hdr = cpu_to_wirelen(tal_count(arg->u1.const_vp)); |
| 102 | |
| 103 | ret = write(fd, (char *)&hdr + len, HEADER_LEN - len); |
| 104 | if (ret <= 0) |
| 105 | return -1; |
| 106 | arg->u2.s += ret; |
| 107 | |
| 108 | /* Both bytes written? Set up for normal write of data. */ |
| 109 | if (arg->u2.s == INSIDE_HEADER_BIT + HEADER_LEN) |
| 110 | arg->u2.s = 0; |
| 111 | |
| 112 | return 0; |
| 113 | } |
| 114 | |
| 115 | static int do_write_wire(int fd, struct io_plan_arg *arg) |
| 116 | { |