mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-12-26 13:05:18 +01:00
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.
This commit is contained in:
parent
a353e14e75
commit
955052cf21
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=89583
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user