Do not sleep after poll returning an error. Blindly copied over from
authorflorian <florian@openbsd.org>
Mon, 28 Apr 2014 15:25:34 +0000 (15:25 +0000)
committerflorian <florian@openbsd.org>
Mon, 28 Apr 2014 15:25:34 +0000 (15:25 +0000)
ping6 to ping by me without thinking clearly.
pointed out by deraadt@
OK jca@

sbin/ping/ping.c
sbin/ping6/ping6.c

index 7a02f7f..314ac4c 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ping.c,v 1.102 2014/04/23 18:16:36 jca Exp $  */
+/*     $OpenBSD: ping.c,v 1.103 2014/04/28 15:25:34 florian Exp $      */
 /*     $NetBSD: ping.c,v 1.20 1995/08/11 22:37:58 cgd Exp $    */
 
 /*
@@ -511,7 +511,7 @@ main(int argc, char *argv[])
                socklen_t               fromlen;
                struct pollfd           pfd;
                ssize_t                 cc;
-               int                     ret, timeout;
+               int                     timeout;
 
                if (options & F_FLOOD) {
                        pinger();
@@ -522,14 +522,7 @@ main(int argc, char *argv[])
                pfd.fd = s;
                pfd.events = POLLIN;
 
-               ret = poll(&pfd, 1, timeout);
-               if (ret < 0) {
-                       if (errno != EINTR) {
-                               warn("poll");
-                               sleep(1);
-                       }
-                       continue;
-               } else if (ret == 0)
+               if (poll(&pfd, 1, timeout) <= 0)
                        continue;
 
                fromlen = sizeof(from);
index 701bc0a..3c12625 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ping6.c,v 1.89 2014/04/23 18:16:36 jca Exp $  */
+/*     $OpenBSD: ping6.c,v 1.90 2014/04/28 15:25:34 florian Exp $      */
 /*     $KAME: ping6.c,v 1.163 2002/10/25 02:19:06 itojun Exp $ */
 
 /*
@@ -892,7 +892,7 @@ main(int argc, char *argv[])
                struct iovec    iov[2];
                struct pollfd   pfd;
                ssize_t         cc;
-               int             ret, timeout;
+               int             timeout;
 
                /* signal handling */
                if (seenalrm) {
@@ -922,14 +922,7 @@ main(int argc, char *argv[])
                pfd.fd = s;
                pfd.events = POLLIN;
 
-               ret = poll(&pfd, 1, timeout);
-               if (ret < 0) {
-                       if (errno != EINTR) {
-                               warn("poll");
-                               sleep(1);
-                       }
-                       continue;
-               } else if (ret == 0)
+               if (poll(&pfd, 1, timeout) <= 0)
                        continue;
 
                m.msg_name = &from;