summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbillf <billf@FreeBSD.org>2002-01-20 12:13:28 +0000
committerbillf <billf@FreeBSD.org>2002-01-20 12:13:28 +0000
commit9979f04a16b895af36d33b812f38d49c27e3f664 (patch)
treec5137ed9c6f0fc88b0d276320a8c1d55786ee30d
parent6bf73776931f9818c3a00a1d0879a3bb4e4e2536 (diff)
downloadFreeBSD-src-9979f04a16b895af36d33b812f38d49c27e3f664.zip
FreeBSD-src-9979f04a16b895af36d33b812f38d49c27e3f664.tar.gz
from select(2):
Any of readfds, writefds, and exceptfds may be given as nil pointers if no descriptors are of interest. neither wfds nor efds were of interest so now they are nil. also, do a little better then making an educated guess for nfds.
-rw-r--r--sbin/nos-tun/nos-tun.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/sbin/nos-tun/nos-tun.c b/sbin/nos-tun/nos-tun.c
index 79519fa..38678fa 100644
--- a/sbin/nos-tun/nos-tun.c
+++ b/sbin/nos-tun/nos-tun.c
@@ -251,8 +251,9 @@ int main (int argc, char **argv)
char buf[0x2000]; /* Packets buffer */
struct ip *ip = (struct ip *)buf;
- fd_set rfds, wfds, efds; /* File descriptors for select() */
+ fd_set rfds; /* File descriptors for select() */
int nfds; /* Return from select() */
+ int lastfd; /* highest fd we care about */
while ((c = getopt(argc, argv, "d:s:t:p:")) != -1) {
@@ -335,12 +336,17 @@ int main (int argc, char **argv)
(void)signal(SIGINT,Finish);
(void)signal(SIGTERM,Finish);
+ if (tun > net)
+ lastfd = tun;
+ else
+ lastfd = net;
+
for (;;) {
/* Set file descriptors for select() */
- FD_ZERO(&rfds); FD_ZERO(&wfds); FD_ZERO(&efds);
+ FD_ZERO(&rfds);
FD_SET(tun,&rfds); FD_SET(net,&rfds);
- nfds = select(net+10,&rfds,&wfds,&efds,NULL);
+ nfds = select(lastfd+1,&rfds,NULL,NULL,NULL);
if(nfds < 0) {
syslog(LOG_ERR,"interrupted select");
close(net);
OpenPOWER on IntegriCloud