summaryrefslogtreecommitdiffstats
path: root/lib/libc/rpc/rpc_dtablesize.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/rpc/rpc_dtablesize.c')
-rw-r--r--lib/libc/rpc/rpc_dtablesize.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/libc/rpc/rpc_dtablesize.c b/lib/libc/rpc/rpc_dtablesize.c
index c4a2ac4..e448624 100644
--- a/lib/libc/rpc/rpc_dtablesize.c
+++ b/lib/libc/rpc/rpc_dtablesize.c
@@ -30,19 +30,34 @@
#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 = "$Id: rpc_dtablesize.c,v 1.1 1993/10/27 05:40:48 paul Exp $";
+static char *rcsid = "rpc_dtablesize.c,v 1.1 1994/08/07 18:36:02 wollman Exp";
#endif
+#include <sys/types.h>
+
/*
* 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).
+ * This can lead to many RPC functions getting back an EINVAL from
+ * select() and bombing all over the place.
+ *
+ * You can apparently get select() to handle values larger than 256
+ * by patching the kernel, but most people aren't likely to know
+ * that. Clamping this function at 256 is a kludge, but it'll have to
+ * do until select()'s descriptor table size can be adjusted dynamically.
+ */
_rpc_dtablesize()
{
static int size;
if (size == 0) {
size = getdtablesize();
+ if (size > FD_SETSIZE)
+ size = FD_SETSIZE;
}
return (size);
}
OpenPOWER on IntegriCloud