Index: lib/libc/net/nsdispatch.c =================================================================== --- lib/libc/net/nsdispatch.c +++ lib/libc/net/nsdispatch.c @@ -334,9 +334,12 @@ static int nss_configure(void) { +#ifdef NS_REREAD_CONF static time_t confmod; - static int already_initialized = 0; struct stat statbuf; +#else /* !NS_REREAD_CONF */ + static int already_initialized = 0; +#endif /* !NS_REREAD_CONF */ int result, isthreaded; const char *path; #ifdef NS_CACHING @@ -353,29 +356,32 @@ if (path == NULL) #endif path = _PATH_NS_CONF; -#ifndef NS_REREAD_CONF +#ifdef NS_REREAD_CONF /* - * Define NS_REREAD_CONF to have nsswitch notice changes + * Define NS_REREAD_CONF to have nsdispatch notice changes * to nsswitch.conf(5) during runtime. This involves calling * stat(2) every time, which can result in performance hit. */ - if (already_initialized) - return (0); - already_initialized = 1; -#endif /* NS_REREAD_CONF */ if (stat(path, &statbuf) != 0) return (0); if (statbuf.st_mtime <= confmod) return (0); +#else /* !NS_REREAD_CONF */ + if (already_initialized) + return (0); + already_initialized = 1; +#endif /* !NS_REREAD_CONF */ if (isthreaded) { (void)_pthread_rwlock_unlock(&nss_lock); result = _pthread_rwlock_wrlock(&nss_lock); if (result != 0) return (result); +#ifdef NS_REREAD_CONF if (stat(path, &statbuf) != 0) goto fin; if (statbuf.st_mtime <= confmod) goto fin; +#endif /* NS_REREAD_CONF */ } _nsyyin = fopen(path, "re"); if (_nsyyin == NULL) @@ -384,13 +390,17 @@ (vector_free_elem)ns_dbt_free); VECTOR_FREE(_nsmod, &_nsmodsize, sizeof(*_nsmod), (vector_free_elem)ns_mod_free); +#ifdef NS_REREAD_CONF if (confmod == 0) +#endif /* NS_REREAD_CONF */ (void)atexit(nss_atexit); nss_load_builtin_modules(); _nsyyparse(); (void)fclose(_nsyyin); vector_sort(_nsmap, _nsmapsize, sizeof(*_nsmap), string_compare); +#ifdef NS_REREAD_CONF confmod = statbuf.st_mtime; +#endif /* NS_REREAD_CONF */ #ifdef NS_CACHING handle = libc_dlopen(NULL, RTLD_LAZY | RTLD_GLOBAL);