Skip to content

Commit

Permalink
wire: optimize sending packets now we can return EAGAIN.
Browse files Browse the repository at this point in the history
Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Jun 4, 2024
1 parent 7cb13db commit 50b7a4a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions wire/wire_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@ static int do_read_wire(int fd, struct io_plan_arg *arg)
ssize_t ret;

/* Still reading header? */
if (arg->u2.s & INSIDE_HEADER_BIT)
return do_read_wire_header(fd, arg);
if (arg->u2.s & INSIDE_HEADER_BIT) {
ret = do_read_wire_header(fd, arg);
/* If this is OK, and finished header, we continue below. */
if (ret != 0 || (arg->u2.s & INSIDE_HEADER_BIT))
return ret;
}

/* Normal read */
ret = read(fd, arg->u1.cp, arg->u2.s);
Expand Down Expand Up @@ -107,8 +111,12 @@ static int do_write_wire(int fd, struct io_plan_arg *arg)
size_t totlen = tal_bytelen(arg->u1.cp);

/* Still writing header? */
if (arg->u2.s & INSIDE_HEADER_BIT)
return do_write_wire_header(fd, arg);
if (arg->u2.s & INSIDE_HEADER_BIT) {
ret = do_write_wire_header(fd, arg);
/* If this is OK, and finished header, we continue below. */
if (ret != 0 || (arg->u2.s & INSIDE_HEADER_BIT))
return ret;
}

/* Normal write */
ret = write(fd, arg->u1.cp + arg->u2.s, totlen - arg->u2.s);
Expand Down

0 comments on commit 50b7a4a

Please sign in to comment.