Skip to content

Commit a5c756c

Browse files
committed
remote: handle EINTR error
In the case of an interrupt, try reading the data again. This may not be the most considerate thing to do, but it will read th data.
1 parent 93c5b5c commit a5c756c

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

lib/CL/devices/remote/communication.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,13 @@ connection_read_full (remote_connection_t *connection,
319319
res = read (connection->fd, ptr + readb, remain);
320320
if (res < 0)
321321
{ /* ERROR */
322+
323+
/* In the case of these errors, try again. */
324+
int e = errno;
325+
if (e == EAGAIN || e == EWOULDBLOCK || e == EINTR)
326+
continue;
327+
POCL_MSG_ERR ("error reading remote data: %d (%s).\n", errno,
328+
strerror (errno));
322329
return -1;
323330
}
324331
if (res == 0)
@@ -350,7 +357,7 @@ connection_write_full (remote_connection_t *connection,
350357
if (res < 0)
351358
{
352359
int e = errno;
353-
if (e == EAGAIN || e == EWOULDBLOCK)
360+
if (e == EAGAIN || e == EWOULDBLOCK || e == EINTR)
354361
continue;
355362
else
356363
return -1;

pocld/connection.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ ssize_t Connection::writeFull(const void *Source, size_t Bytes) {
6868
Res = ::write(Fd, Ptr + Written, Remaining);
6969
if (Res < 0) {
7070
int e = errno;
71-
if (e == EAGAIN || e == EWOULDBLOCK)
71+
if (e == EAGAIN || e == EWOULDBLOCK || e == EINTR)
7272
continue;
7373
else
7474
return -1;
@@ -93,7 +93,7 @@ int Connection::readFull(void *Destination, size_t Bytes) {
9393
res = ::read(Fd, Ptr + readb, Remain);
9494
if (res < 0) {
9595
int e = errno;
96-
if (e == EAGAIN || e == EWOULDBLOCK)
96+
if (e == EAGAIN || e == EWOULDBLOCK || e == EINTR)
9797
continue;
9898
else
9999
return -1;

0 commit comments

Comments
 (0)