Skip to content

Commit

Permalink
Bug #4319: Treat EINTR like EAGAIN
Browse files Browse the repository at this point in the history
This bug described a situation where an ongoing transfer would be
prematurely aborted when one of our timers fired.  The timer could have
fired for an unrelated reason, but if we were in the process of reading
or writing with pr_netio_read() or pr_netio_write(), those calls would
be interrupted with errno set to EINTR, and an error would be returned.
Then pr_data_xfer() would abort the transfer.

EAGAIN was already being handled properly, and we can just use the same
treatment for EINTR so that we only respond to the timers we should
actually care about.
  • Loading branch information
Justin Maggard committed Oct 17, 2017
1 parent 0e9987f commit f09f0c6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ int pr_data_xfer(char *cl_buf, size_t cl_size) {
while (len < 0) {
int xerrno = errno;

if (xerrno == EAGAIN) {
if (xerrno == EAGAIN || xerrno == EINTR) {
/* Since our socket is in non-blocking mode, read(2) can return
* EAGAIN if there is no data yet for us. Handle this by
* delaying temporarily, then trying again.
Expand Down Expand Up @@ -1265,7 +1265,7 @@ int pr_data_xfer(char *cl_buf, size_t cl_size) {
while (len < 0) {
int xerrno = errno;

if (xerrno == EAGAIN) {
if (xerrno == EAGAIN || xerrno == EINTR) {
/* Since our socket is in non-blocking mode, read(2) can return
* EAGAIN if there is no data yet for us. Handle this by
* delaying temporarily, then trying again.
Expand Down Expand Up @@ -1362,7 +1362,7 @@ int pr_data_xfer(char *cl_buf, size_t cl_size) {
while (bwrote < 0) {
int xerrno = errno;

if (xerrno == EAGAIN) {
if (xerrno == EAGAIN || xerrno == EINTR) {
/* Since our socket is in non-blocking mode, write(2) can return
* EAGAIN if there is not enough from for our data yet. Handle
* this by delaying temporarily, then trying again.
Expand Down

0 comments on commit f09f0c6

Please sign in to comment.