summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2001-09-05 00:22:50 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2001-09-05 00:22:50 +0000
commit7995821039af4cc3cd76a2d253983b6b9d94d3c3 (patch)
treed60dc39324bda1b82014487a313b7f5f369b1d02
parentfc3978334c77eead8f6ea6ca3140cee54abfd5c4 (diff)
do not select(20, ...)
-rw-r--r--usr.sbin/lpr/lpd/lpd.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/usr.sbin/lpr/lpd/lpd.c b/usr.sbin/lpr/lpd/lpd.c
index ed7470d1a74..7d1833e083c 100644
--- a/usr.sbin/lpr/lpd/lpd.c
+++ b/usr.sbin/lpr/lpd/lpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lpd.c,v 1.20 2001/09/04 23:35:59 millert Exp $ */
+/* $OpenBSD: lpd.c,v 1.21 2001/09/05 00:22:49 deraadt Exp $ */
/* $NetBSD: lpd.c,v 1.7 1996/04/24 14:54:06 mrg Exp $ */
/*
@@ -45,7 +45,7 @@ static const char copyright[] =
#if 0
static const char sccsid[] = "@(#)lpd.c 8.7 (Berkeley) 5/10/95";
#else
-static const char rcsid[] = "$OpenBSD: lpd.c,v 1.20 2001/09/04 23:35:59 millert Exp $";
+static const char rcsid[] = "$OpenBSD: lpd.c,v 1.21 2001/09/05 00:22:49 deraadt Exp $";
#endif
#endif /* not lint */
@@ -125,6 +125,7 @@ main(argc, argv)
{
int f, lfd, funix, finet, options, fromlen;
fd_set defreadfds;
+ int maxfd = 0;
struct sockaddr_un un, fromunix;
struct sockaddr_in sin, frominet;
sigset_t mask, omask;
@@ -221,6 +222,8 @@ main(argc, argv)
sigprocmask(SIG_SETMASK, &omask, NULL);
FD_ZERO(&defreadfds);
FD_SET(funix, &defreadfds);
+ if (funix > maxfd)
+ maxfd = funix;
listen(funix, 5);
finet = socket(AF_INET, SOCK_STREAM, 0);
if (finet >= 0) {
@@ -248,6 +251,8 @@ main(argc, argv)
mcleanup(0);
}
FD_SET(finet, &defreadfds);
+ if (finet > maxfd)
+ maxfd = finet;
listen(finet, 5);
}
/*
@@ -260,7 +265,7 @@ main(argc, argv)
fd_set readfds;
FD_COPY(&defreadfds, &readfds);
- nfds = select(20, &readfds, 0, 0, 0);
+ nfds = select(maxfd + 1, &readfds, 0, 0, 0);
if (nfds <= 0) {
if (nfds < 0 && errno != EINTR)
syslog(LOG_WARNING, "select: %m");