Skip to content

Commit

Permalink
handle EWOULDBLOCK. Helps with #5286
Browse files Browse the repository at this point in the history
  • Loading branch information
alandekok committed Jan 29, 2024
1 parent 56c70e1 commit 45f465b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/listen/radius/proto_radius_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,23 @@ static ssize_t mod_read(fr_listen_t *li, UNUSED void **packet_ctx, fr_time_t *re
*/
data_size = read(thread->sockfd, buffer + *leftover, buffer_len - *leftover);
if (data_size < 0) {
switch (errno) {
#if defined(EWOULDBLOCK) && (EWOULDBLOCK != EAGAIN)
case EWOULDBLOCK:
#endif
case EAGAIN:
/*
* We didn't read any data leave the buffers alone.
*
* i.e. if we had a partial packet in the buffer and we didn't read any data,
* then the partial packet is still left in the buffer.
*/
return 0;

default:
break;
}

PDEBUG2("proto_radius_tcp got read error %zd", data_size);
return data_size;
}
Expand Down
17 changes: 17 additions & 0 deletions src/listen/tacacs/proto_tacacs_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,23 @@ static ssize_t mod_read(fr_listen_t *li, UNUSED void **packet_ctx, fr_time_t *re
*/
data_size = read(thread->sockfd, buffer + (*leftover), buffer_len - (*leftover));
if (data_size < 0) {
switch (errno) {
#if defined(EWOULDBLOCK) && (EWOULDBLOCK != EAGAIN)
case EWOULDBLOCK:
#endif
case EAGAIN:
/*
* We didn't read any data leave the buffers alone.
*
* i.e. if we had a partial packet in the buffer and we didn't read any data,
* then the partial packet is still left in the buffer.
*/
return 0;

default:
break;
}

ERROR("proto_tacacs_tcp got read error (%zd) - %s", data_size, fr_syserror(errno));
return data_size;
}
Expand Down

0 comments on commit 45f465b

Please sign in to comment.