From e033d1da1ceb3ed665f41f219cdb59c3205aacfe Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Fri, 3 Aug 2012 01:15:30 +0000 Subject: [PATCH] EINTR requires special handling --- daemon/call.c | 6 ++++-- daemon/control_udp.c | 4 +++- daemon/streambuf.c | 12 +++++++++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index 301f99dd8..fc8746a65 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -294,7 +294,7 @@ forward: ret = sendmsg(p->fd, &mh, 0); - if (ret == -1 && errno != EINTR && errno != EAGAIN && errno != EWOULDBLOCK) { + if (ret == -1) { r->stats.errors++; m->statsps.errors++; return -1; @@ -332,7 +332,9 @@ static void stream_readable(int fd, void *p, uintptr_t u) { ret = recvfrom(fd, buf, sizeof(buf), 0, (struct sockaddr *) &ss, &sinlen); if (ret < 0) { - if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) + if (errno == EINTR) + continue; + if (errno == EAGAIN || errno == EWOULDBLOCK) break; stream_closed(fd, r, 0); break; diff --git a/daemon/control_udp.c b/daemon/control_udp.c index d452a0318..b1143f28c 100644 --- a/daemon/control_udp.c +++ b/daemon/control_udp.c @@ -40,7 +40,9 @@ next: sin_len = sizeof(sin); len = recvfrom(fd, buf, sizeof(buf) - 1, 0, (struct sockaddr *) &sin, &sin_len); if (len < 0) { - if (errno != EWOULDBLOCK && errno != EAGAIN && errno != EINTR) + if (errno == EINTR) + goto next; + if (errno != EWOULDBLOCK && errno != EAGAIN) mylog(LOG_WARNING, "Error reading from UDP socket"); return; } diff --git a/daemon/streambuf.c b/daemon/streambuf.c index 51d0594f7..40e8506c2 100644 --- a/daemon/streambuf.c +++ b/daemon/streambuf.c @@ -45,7 +45,9 @@ int streambuf_writeable(struct streambuf *b) { ret = write(b->fd, b->buf->str, out); if (ret < 0) { - if (errno != EINTR && errno != EAGAIN && errno != EWOULDBLOCK) + if (errno == EINTR) + continue; + if (errno != EAGAIN && errno != EWOULDBLOCK) return -1; ret = 0; } @@ -74,7 +76,9 @@ int streambuf_readable(struct streambuf *b) { if (ret == 0) return -1; if (ret < 0) { - if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) + if (errno == EINTR) + continue; + if (errno == EAGAIN || errno == EWOULDBLOCK) break; return -1; } @@ -155,7 +159,9 @@ void streambuf_write(struct streambuf *b, const char *s, unsigned int len) { ret = write(b->fd, s, out); if (ret < 0) { - if (errno != EINTR && errno != EAGAIN && errno != EWOULDBLOCK) { + if (errno == EINTR) + continue; + if (errno != EAGAIN && errno != EWOULDBLOCK) { poller_error(b->poller, b->fd); break; }