From c9eeb5835cf759eb0d9672faf7825f31a78e5b89 Mon Sep 17 00:00:00 2001 From: florian Date: Mon, 28 Apr 2014 15:25:34 +0000 Subject: [PATCH] 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@ --- sbin/ping/ping.c | 13 +++---------- sbin/ping6/ping6.c | 13 +++---------- 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; -- 2.20.1