From 775933e89544da31c0cf22cd0937614f5616c50e Mon Sep 17 00:00:00 2001 From: Jeffrey Hutzelman Date: Thu, 8 Jul 2004 06:16:55 +0000 Subject: [PATCH] rx-lwp-fdsetsize-20040708 FIXES 5615 limit our fd set size so we don't "lose" fds. --- src/lwp/iomgr.c | 14 +++++++++++++- src/rx/rx_globals.c | 7 +++++++ src/rx/rx_lwp.c | 7 +++++++ src/vol/fssync.c | 20 +++++++++++++++----- 4 files changed, 42 insertions(+), 6 deletions(-) diff --git a/src/lwp/iomgr.c b/src/lwp/iomgr.c index 388987c..9c26b84 100644 --- a/src/lwp/iomgr.c +++ b/src/lwp/iomgr.c @@ -21,6 +21,18 @@ IO Manager routines & server process for VICE server. */ +/* This controls the size of an fd_set; it must be defined early before + * the system headers define that type and the macros that operate on it. + * Its value should be as large as the maximum file descriptor limit we + * are likely to run into on any platform. Right now, that is 65536 + * which is the default hard fd limit on Solaris 9 */ +/* We don't do this on Windows because on that platform there is code + * which allocates fd_set's on the stack (IOMGR_Sleep on Win9x, and + * FDSetAnd on WinNT) */ +#ifndef _WIN32 +#define FD_SETSIZE 65536 +#endif + #include #include @@ -177,7 +189,7 @@ static _go32_dpmi_seginfo callback_info; /* fd_set pool managment. * Use the pool instead of creating fd_set's on the stack. fd_set's can be - * 2K in size, so making three could put 6K in the limited space of an LWP + * 8K in size, so making three could put 24K in the limited space of an LWP * stack. */ struct IOMGR_fd_set { diff --git a/src/rx/rx_globals.c b/src/rx/rx_globals.c index 57ad70c..1dacd68 100644 --- a/src/rx/rx_globals.c +++ b/src/rx/rx_globals.c @@ -9,6 +9,13 @@ /* RX: Globals for internal use, basically */ +/* This controls the size of an fd_set; it must be defined early before + * the system headers define that type and the macros that operate on it. + * Its value should be as large as the maximum file descriptor limit we + * are likely to run into on any platform. Right now, that is 65536 + * which is the default hard fd limit on Solaris 9 */ +#define FD_SETSIZE 65536 + #include #ifdef KERNEL #include "afs/param.h" diff --git a/src/rx/rx_lwp.c b/src/rx/rx_lwp.c index f8b532e..9aa4ffc 100644 --- a/src/rx/rx_lwp.c +++ b/src/rx/rx_lwp.c @@ -9,6 +9,13 @@ /* rx_user.c contains routines specific to the user space UNIX implementation of rx */ +/* This controls the size of an fd_set; it must be defined early before + * the system headers define that type and the macros that operate on it. + * Its value should be as large as the maximum file descriptor limit we + * are likely to run into on any platform. Right now, that is 65536 + * which is the default hard fd limit on Solaris 9 */ +#define FD_SETSIZE 65536 + #include #include diff --git a/src/vol/fssync.c b/src/vol/fssync.c index 378ef46..a4a6d15 100644 --- a/src/vol/fssync.c +++ b/src/vol/fssync.c @@ -21,6 +21,7 @@ int newVLDB; /* Compatibility flag */ #endif static int newVLDB = 1; + #ifndef AFS_PTHREAD_ENV #define USUAL_PRIORITY (LWP_MAX_PRIORITY - 2) @@ -35,6 +36,14 @@ static int newVLDB = 1; fsync.c File server synchronization with external volume utilities. */ + +/* This controls the size of an fd_set; it must be defined early before + * the system headers define that type and the macros that operate on it. + * Its value should be as large as the maximum file descriptor limit we + * are likely to run into on any platform. Right now, that is 65536 + * which is the default hard fd limit on Solaris 9 */ +#define FD_SETSIZE 65536 + #include #include @@ -276,6 +285,8 @@ getport(struct sockaddr_in *addr) return sd; } +static fd_set FSYNC_readfds; + static void FSYNC_sync() { @@ -331,18 +342,17 @@ FSYNC_sync() InitHandler(); AcceptOn(); for (;;) { - fd_set readfds; int maxfd; - GetHandler(&readfds, &maxfd); + GetHandler(&FSYNC_readfds, &maxfd); /* Note: check for >= 1 below is essential since IOMGR_select * doesn't have exactly same semantics as select. */ #ifdef AFS_PTHREAD_ENV - if (select(maxfd + 1, &readfds, NULL, NULL, NULL) >= 1) + if (select(maxfd + 1, &FSYNC_readfds, NULL, NULL, NULL) >= 1) #else /* AFS_PTHREAD_ENV */ - if (IOMGR_Select(maxfd + 1, &readfds, NULL, NULL, NULL) >= 1) + if (IOMGR_Select(maxfd + 1, &FSYNC_readfds, NULL, NULL, NULL) >= 1) #endif /* AFS_PTHREAD_ENV */ - CallHandler(&readfds); + CallHandler(&FSYNC_readfds); } } -- 1.7.1