summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2014-04-28 15:25:35 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2014-04-28 15:25:35 +0000
commit01902b13133bd45eaa86e59d8e92aef02da28a3a (patch)
tree85c46d6cea47664d69095429361bc6d992168d03 /sbin
parenta130f4a7beb3c01b4333e994c59556a8dda5e14a (diff)
Do not sleep after poll returning an error. Blindly copied over from
ping6 to ping by me without thinking clearly. pointed out by deraadt@ OK jca@
Diffstat (limited to 'sbin')
-rw-r--r--sbin/ping/ping.c13
-rw-r--r--sbin/ping6/ping6.c13
2 files changed, 6 insertions, 20 deletions
diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c
index 7a02f7fa9d1..314ac4c3c57 100644
--- a/sbin/ping/ping.c
+++ b/sbin/ping/ping.c
@@ -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);
diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c
index 701bc0a934a..3c126259dde 100644
--- a/sbin/ping6/ping6.c
+++ b/sbin/ping6/ping6.c
@@ -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;