From: Jeffrey Hutzelman Date: Mon, 18 Oct 2004 06:52:23 +0000 (+0000) Subject: STABLE12-rx-lwp-fdsetsize-20040708 X-Git-Tag: openafs-stable-1_2_12~10 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=29fce316c10cfd47df08517e43b304bc59699c85;p=packages%2Fo%2Fopenafs.git STABLE12-rx-lwp-fdsetsize-20040708 FIXES 5615 limit our fd set size so we don't "lose" fds. (cherry picked from commit 775933e89544da31c0cf22cd0937614f5616c50e) --- diff --git a/src/lwp/iomgr.c b/src/lwp/iomgr.c index f5d176b72..e5dfcbd02 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 4d7701c0c..e77cfa647 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 0e6ffb557..dad356051 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 701c31ed3..411d6f032 100644 --- a/src/vol/fssync.c +++ b/src/vol/fssync.c @@ -35,6 +35,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 @@ -246,6 +254,8 @@ static int getport(addr) return sd; } +static fd_set FSYNC_readfds; + static void FSYNC_sync() { struct sockaddr_in addr; int on = 1; @@ -293,18 +303,17 @@ static void 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); } }