diff options
author | peter <peter@FreeBSD.org> | 1996-12-30 18:41:20 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1996-12-30 18:41:20 +0000 |
commit | 30336e7710816228ba669ad55fb8233304c882c5 (patch) | |
tree | bf024b4a17e6c8d8fd134286cc123d50dad27a24 /lib/libc/rpc/rpc_dtablesize.c | |
parent | 5e8382f154dadc9702580162151882eb9f97f9d6 (diff) | |
download | FreeBSD-src-30336e7710816228ba669ad55fb8233304c882c5.zip FreeBSD-src-30336e7710816228ba669ad55fb8233304c882c5.tar.gz |
Oops! Bad Idea! (TM)
Restore the clamp on the return value from rpc_dtablesize().. Some programs
(eg: ypserv) use this as an indication of how large svc_fdset is in their
hand-rolled svc_run() loops. The svc_fdset table is maintained by the
rpc library explicitly for compatability with such programs. (It uses
a different variable-sized bitmap itself internally)
Diffstat (limited to 'lib/libc/rpc/rpc_dtablesize.c')
-rw-r--r-- | lib/libc/rpc/rpc_dtablesize.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/libc/rpc/rpc_dtablesize.c b/lib/libc/rpc/rpc_dtablesize.c index 7df2e43..77697fe 100644 --- a/lib/libc/rpc/rpc_dtablesize.c +++ b/lib/libc/rpc/rpc_dtablesize.c @@ -30,7 +30,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)rpc_dtablesize.c 1.2 87/08/11 Copyr 1987 Sun Micro";*/ /*static char *sccsid = "from: @(#)rpc_dtablesize.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "rpc_dtablesize.c,v 1.1 1994/08/07 18:36:02 wollman Exp"; +static char *rcsid = "$Id$"; #endif #include <sys/types.h> @@ -40,12 +40,22 @@ static char *rcsid = "rpc_dtablesize.c,v 1.1 1994/08/07 18:36:02 wollman Exp"; * Cache the result of getdtablesize(), so we don't have to do an * expensive system call every time. */ +/* + * XXX In FreeBSD 2.x, you can have the maximum number of open file + * descriptors be greater than FD_SETSIZE (which us 256 by default). + * + * Since old programs tend to use this call to determine the first arg + * for select(), having this return > FD_SETSIZE is a Bad Idea(TM)! + */ int -_rpc_dtablesize() +_rpc_dtablesize(void) { static int size; - if (size == 0) + if (size == 0) { size = getdtablesize(); + if (size > FD_SETSIZE) + size = FD_SETSIZE; + } return (size); } |