Skip to content

Commit

Permalink
check zero bytes read from O_NDELAY socket
Browse files Browse the repository at this point in the history
  • Loading branch information
dtsecon committed Feb 6, 2022
1 parent b0c0f18 commit 5500649
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions clients/upssched.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,15 +497,21 @@ static int sock_read(conn_t *conn)
if ((ret == -1) && (errno == EAGAIN))
return 0;

if (ret == 0) /* nothing to parse yet */
continue;
/* O_NDELAY with zero bytes means nothing to read but
since read() follows a succesful select() with
ready file descriptor, ret shouldn't be 0. */
if (ret == 0)
continue;

/* some other problem */
return -1; /* error */
}

ret = pconf_char(&conn->ctx, ch);

if (ret == 0) /* nothing to parse yet */
continue;

if (ret == -1) {
upslogx(LOG_NOTICE, "Parse error on sock: %s",
conn->ctx.errmsg);
Expand Down

0 comments on commit 5500649

Please sign in to comment.