Skip to content

Commit

Permalink
io: check connection error only on net_io_read
Browse files Browse the repository at this point in the history
Signed-off-by: Takahiro Yamashita <[email protected]>
  • Loading branch information
nokute78 authored and edsiper committed Jan 24, 2022
1 parent b6668b1 commit d5f2c65
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/flb_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,15 +316,10 @@ static FLB_INLINE int net_io_write_async(struct flb_coro *co,
static ssize_t fd_io_read(int fd, void *buf, size_t len);
static ssize_t net_io_read(struct flb_upstream_conn *u_conn,
void *buf, size_t len)
{
return fd_io_read(u_conn->fd, buf, len);
}

static ssize_t fd_io_read(int fd, void *buf, size_t len)
{
int ret;

ret = recv(fd, buf, len, 0);
ret = fd_io_read(u_conn->fd, buf, len);
if (ret == -1) {
ret = FLB_WOULDBLOCK();
if (ret) {
Expand All @@ -340,6 +335,18 @@ static ssize_t fd_io_read(int fd, void *buf, size_t len)
return ret;
}

static ssize_t fd_io_read(int fd, void *buf, size_t len)
{
int ret;

ret = recv(fd, buf, len, 0);
if (ret == -1) {
return -1;
}

return ret;
}

static FLB_INLINE ssize_t net_io_read_async(struct flb_coro *co,
struct flb_upstream_conn *u_conn,
void *buf, size_t len)
Expand Down

0 comments on commit d5f2c65

Please sign in to comment.