From 305cc423106c83369ffaeb67be8685b031c59f88 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Love=20H=C3=B6rnquist-=C3=85strand?= Date: Sun, 21 Apr 2002 21:27:47 +0000 Subject: [PATCH] file server now works usefully on netbsd (cherry picked from commit efa250bd1c4bf2c8d6ac74d9f866a842a020d7cf) --- src/vol/ihandle.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/vol/ihandle.c b/src/vol/ihandle.c index 569552b34..9d466d2ce 100644 --- a/src/vol/ihandle.c +++ b/src/vol/ihandle.c @@ -25,7 +25,7 @@ RCSID("$Header$"); #include #include #include -#ifdef AFS_SUN5_ENV +#if defined(AFS_SUN5_ENV) || defined(AFS_NBSD_ENV) #include #include #endif @@ -94,9 +94,6 @@ void ih_glock_init() /* Initialize the file descriptor cache */ void ih_Initialize() { int i; -#ifdef AFS_SUN5_ENV - struct rlimit rlim; -#endif /* AFS_SUN5_ENV */ assert(!ih_Inited); ih_Inited = 1; DLL_INIT_LIST(ihAvailHead, ihAvailTail); @@ -107,13 +104,27 @@ void ih_Initialize() { } #if defined(AFS_NT40_ENV) fdMaxCacheSize = FD_MAX_CACHESIZE; -#elif defined(AFS_SUN5_ENV) - assert(getrlimit(RLIMIT_NOFILE, &rlim) == 0); - rlim.rlim_cur = rlim.rlim_max; - assert(setrlimit(RLIMIT_NOFILE, &rlim) == 0); - fdMaxCacheSize = rlim.rlim_cur-FD_HANDLE_SETASIDE; - fdMaxCacheSize = MIN(fdMaxCacheSize, FD_MAX_CACHESIZE); - assert(fdMaxCacheSize > 0); +#elif defined(AFS_SUN5_ENV) || defined(AFS_NBSD_ENV) + { + struct rlimit rlim; + assert(getrlimit(RLIMIT_NOFILE, &rlim) == 0); + rlim.rlim_cur = rlim.rlim_max; + assert(setrlimit(RLIMIT_NOFILE, &rlim) == 0); + fdMaxCacheSize = rlim.rlim_cur-FD_HANDLE_SETASIDE; +#ifdef AFS_NBSD_ENV + /* XXX this is to avoid using up all system fd netbsd is + * somewhat broken and have set maximum fd for a root process + * to the same as system fd that is avaible, so if the + * fileserver uses all up process fds, all system fd will be + * used up too ! + * + * Check for this better + */ + fdMaxCacheSize /= 4; +#endif + fdMaxCacheSize = MIN(fdMaxCacheSize, FD_MAX_CACHESIZE); + assert(fdMaxCacheSize > 0); + } #elif defined(AFS_HPUX_ENV) /* Avoid problems with "UFSOpen: igetinode failed" panics on HPUX 11.0 */ fdMaxCacheSize = 0; -- 2.39.5