summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2003-08-19 19:41:22 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2003-08-19 19:41:22 +0000
commit29160c6d8e0f8cb7b672b4da47e9717f93184caf (patch)
tree47bc541e3fd68cf39a56b90b3cdd5e04b2775524 /usr.sbin
parentcfe8fd122f2fb0ab02476d2d87bc498681a14a8b (diff)
use poll instead of select; dhartmei ok
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/timed/timed/globals.h3
-rw-r--r--usr.sbin/timed/timed/measure.c17
-rw-r--r--usr.sbin/timed/timed/readmsg.c13
-rw-r--r--usr.sbin/timed/timed/slave.c5
4 files changed, 17 insertions, 21 deletions
diff --git a/usr.sbin/timed/timed/globals.h b/usr.sbin/timed/timed/globals.h
index 9e1dbc843e4..ae9df042a6e 100644
--- a/usr.sbin/timed/timed/globals.h
+++ b/usr.sbin/timed/timed/globals.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: globals.h,v 1.7 2003/06/02 23:36:55 millert Exp $ */
+/* $OpenBSD: globals.h,v 1.8 2003/08/19 19:41:21 deraadt Exp $ */
/*-
* Copyright (c) 1985 The Regents of the University of California.
@@ -46,6 +46,7 @@
#include <string.h>
#include <syslog.h>
#include <syslog.h>
+#include <poll.h>
#include <unistd.h>
#include <protocols/timed.h>
diff --git a/usr.sbin/timed/timed/measure.c b/usr.sbin/timed/timed/measure.c
index 0313aa9c9f6..968a5956863 100644
--- a/usr.sbin/timed/timed/measure.c
+++ b/usr.sbin/timed/timed/measure.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: measure.c,v 1.11 2003/07/18 22:58:56 david Exp $ */
+/* $OpenBSD: measure.c,v 1.12 2003/08/19 19:41:21 deraadt Exp $ */
/*-
* Copyright (c) 1985, 1993 The Regents of the University of California.
@@ -38,6 +38,7 @@ static char sccsid[] = "@(#)measure.c 5.1 (Berkeley) 5/11/93";
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <signal.h>
+#include <poll.h>
#define MSEC_DAY (SECDAY*1000)
@@ -66,7 +67,7 @@ measure(u_long maxmsec, u_long wmsec, char *hname, struct sockaddr_in *addr,
int measure_status;
int rcvcount, trials;
int cc, count;
- fd_set ready;
+ struct pollfd pfd[1];
long sendtime, recvtime, histime1, histime2;
long idelta, odelta, total;
long min_idelta, min_odelta;
@@ -94,11 +95,11 @@ measure(u_long maxmsec, u_long wmsec, char *hname, struct sockaddr_in *addr,
/*
* empty the icmp input queue
*/
- FD_ZERO(&ready);
+ pfd[0].fd = sock_raw;
+ pfd[0].events = POLLIN;
for (;;) {
tout.tv_sec = tout.tv_usec = 0;
- FD_SET(sock_raw, &ready);
- if (select(sock_raw+1, &ready, 0,0, &tout)) {
+ if (poll(pfd, 1, tout.tv_sec * 1000)) {
length = sizeof(struct sockaddr_in);
siginterrupt(SIGINT, 1);
cc = recvfrom(sock_raw, (char *)packet, PACKET_IN, 0,
@@ -128,8 +129,6 @@ measure(u_long maxmsec, u_long wmsec, char *hname, struct sockaddr_in *addr,
oicp->icmp_ttime = 0;
oicp->icmp_seq = seqno;
- FD_ZERO(&ready);
-
(void)gettimeofday(&tdone, 0);
mstotvround(&tout, maxmsec);
timeradd(&tdone, &tout, &tdone); /* when we give up */
@@ -177,9 +176,7 @@ measure(u_long maxmsec, u_long wmsec, char *hname, struct sockaddr_in *addr,
if (tout.tv_sec < 0)
tout.tv_sec = 0;
- FD_SET(sock_raw, &ready);
- count = select(sock_raw+1, &ready, (fd_set *)0,
- (fd_set *)0, &tout);
+ count = poll(pfd, 1, tout.tv_sec * 1000);
(void)gettimeofday(&tcur, (struct timezone *)0);
if (count <= 0)
break;
diff --git a/usr.sbin/timed/timed/readmsg.c b/usr.sbin/timed/timed/readmsg.c
index be36e13d3e1..e2613814188 100644
--- a/usr.sbin/timed/timed/readmsg.c
+++ b/usr.sbin/timed/timed/readmsg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: readmsg.c,v 1.13 2003/06/12 21:09:48 deraadt Exp $ */
+/* $OpenBSD: readmsg.c,v 1.14 2003/08/19 19:41:21 deraadt Exp $ */
/*-
* Copyright (c) 1985, 1993 The Regents of the University of California.
@@ -73,7 +73,7 @@ readmsg(int type, char *machfrom, struct timeval *intvl,
{
int length;
socklen_t salength;
- fd_set ready;
+ struct pollfd pfd[1];
static struct tsplist *head = &msgslist;
static struct tsplist *tail = &msgslist;
static int msgcnt = 0;
@@ -161,13 +161,12 @@ again:
/*
* If the message was not in the linked list, it may still be
* coming from the network. Set the timer and wait
- * on a select to read the next incoming message: if it is the
+ * on a poll to read the next incoming message: if it is the
* right one, return it, otherwise insert it in the linked list.
*/
(void)gettimeofday(&rtout, 0);
timeradd(&rtout, intvl, &rtout);
- FD_ZERO(&ready);
for (;;) {
(void)gettimeofday(&rtime, 0);
timersub(&rtout, &rtime, &rwait);
@@ -191,9 +190,9 @@ again:
traceoff("Tracing ended for cause at %s\n");
}
- FD_SET(sock, &ready);
- if (!select(sock+1, &ready, (fd_set *)0, (fd_set *)0,
- &rwait)) {
+ pfd[0].fd = sock;
+ pfd[0].events = POLLIN;
+ if (!poll(pfd, 1, rwait.tv_sec * 1000)) {
if (rwait.tv_sec == 0 && rwait.tv_usec == 0)
return(0);
continue;
diff --git a/usr.sbin/timed/timed/slave.c b/usr.sbin/timed/timed/slave.c
index 127cbf3656a..4df32931f75 100644
--- a/usr.sbin/timed/timed/slave.c
+++ b/usr.sbin/timed/timed/slave.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: slave.c,v 1.10 2003/06/26 21:36:40 deraadt Exp $ */
+/* $OpenBSD: slave.c,v 1.11 2003/08/19 19:41:21 deraadt Exp $ */
/*-
* Copyright (c) 1985, 1993 The Regents of the University of California.
@@ -682,7 +682,6 @@ answerdelay(void)
timeout.tv_sec = 0;
timeout.tv_usec = casual(1, 100 * 1000);
- (void)select(0, (fd_set *)NULL, (fd_set *)NULL, (fd_set *)NULL,
- &timeout);
+ (void)select(0, NULL, NULL, NULL, &timeout);
return;
}