summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Straz <nstraz@redhat.com>2014-08-20 18:10:44 -0400
committerNathan Straz <nstraz@redhat.com>2014-08-20 18:12:52 -0400
commit50d61417f4969bba1be6a7070e2c7625e5c32e6e (patch)
treecb95118801213670ea3438bde145608cfb2fa6f6
parent10a4f4723dccc3a17f95756fe169e44bd4475241 (diff)
downloadqarsh-50d61417f4969bba1be6a7070e2c7625e5c32e6e.tar.gz
qarsh-50d61417f4969bba1be6a7070e2c7625e5c32e6e.tar.xz
qarsh-50d61417f4969bba1be6a7070e2c7625e5c32e6e.zip
[sockutil] Handle EINTR in send/recv_packet
When we caused system calls not to be restarted on SIGCHLD for select() in qarshd, we also allowed all system calls to be interrupted, including read() and write() in recv/send_packet(). Go back through the loop when we are interrupted.
-rw-r--r--sockutil.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sockutil.c b/sockutil.c
index a86290d..641b9ce 100644
--- a/sockutil.c
+++ b/sockutil.c
@@ -113,6 +113,7 @@ recv_packet(int fd)
do {
if ((ret = read(fd, (char *)psbuf+bufused, sizeof packetsize - bufused)) < 0) {
+ if (errno == EINTR) continue;
lprintf(LOG_ERR, "Read error while reading packet size: %s\n", strerror(errno));
return NULL;
} else if (ret == 0) {
@@ -130,6 +131,7 @@ recv_packet(int fd)
bufused = 0;
do {
if ((ret = read(fd, buf+bufused, packetsize-bufused)) < 0) {
+ if (errno == EINTR) continue;
lprintf(LOG_ERR, "Read error while reading packet data: %s\n", strerror(errno));
return NULL;
}
@@ -159,6 +161,7 @@ send_packet(int fd, struct qa_packet *qp)
do {
if ((ret = write(fd, (char *)psbuf+bufused, sizeof packetsize - bufused)) < 0) {
+ if (errno == EINTR) continue;
lprintf(LOG_ERR, "Write error while sending packet size: %s\n", strerror(errno));
return -1;
}
@@ -168,6 +171,7 @@ send_packet(int fd, struct qa_packet *qp)
bufused = 0;
do {
if ((ret = write(fd, buf+bufused, len - bufused)) < 0) {
+ if (errno == EINTR) continue;
lprintf(LOG_ERR, "Write error while sending packet data: %s\n", strerror(errno));
return -1;
}