diff options
author | Nathan Straz <nstraz@redhat.com> | 2014-08-20 18:10:44 -0400 |
---|---|---|
committer | Nathan Straz <nstraz@redhat.com> | 2014-08-20 18:12:52 -0400 |
commit | 50d61417f4969bba1be6a7070e2c7625e5c32e6e (patch) | |
tree | cb95118801213670ea3438bde145608cfb2fa6f6 /sockutil.c | |
parent | 10a4f4723dccc3a17f95756fe169e44bd4475241 (diff) | |
download | qarsh-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.
Diffstat (limited to 'sockutil.c')
-rw-r--r-- | sockutil.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -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; } |