changeset 11648:2bba1342ff22

6922943 nscd failing because fd limit is too low when using files backend with enumeration
author Julian Pullen <Julian.Pullen@Sun.COM>
date Fri, 12 Feb 2010 10:17:43 +0000
parents 43b978b1e5e7
children 3eb4beedba47
files usr/src/cmd/nscd/nscd_selfcred.c usr/src/cmd/nscd/server.c
diffstat 2 files changed, 13 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/nscd/nscd_selfcred.c	Thu Feb 11 12:28:02 2010 +0530
+++ b/usr/src/cmd/nscd/nscd_selfcred.c	Fri Feb 12 10:17:43 2010 +0000
@@ -20,12 +20,10 @@
  */
 
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <synch.h>
@@ -45,8 +43,6 @@
 #include <procfs.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-#include <limits.h>
-#include <sys/resource.h>
 #include <libscf.h>
 #include "nscd_door.h"
 #include "nscd_config.h"
@@ -1106,8 +1102,6 @@
 	char	**argv)
 {
 	pid_t	cid;
-	struct	rlimit rl;
-	char	*me = "_nscd_start_forker";
 
 	/* if self cred is not configured, do nothing */
 	if (!_nscd_is_self_cred_on(1, NULL))
@@ -1133,16 +1127,6 @@
 			/* remember process id of the forker */
 			forker_pid = cid;
 
-			/* set NOFILE to unlimited */
-			rl.rlim_cur = rl.rlim_max = RLIM_INFINITY;
-			if (setrlimit(RLIMIT_NOFILE, &rl) < 0) {
-				_NSCD_LOG(NSCD_LOG_SELF_CRED,
-				    NSCD_LOG_LEVEL_ERROR)
-				(me, "Cannot set open file limit: %s\n",
-				    strerror(errno));
-				exit(1);
-			}
-
 			/* enable child nscd management */
 			(void) _nscd_init_cslots();
 			break;
--- a/usr/src/cmd/nscd/server.c	Thu Feb 11 12:28:02 2010 +0530
+++ b/usr/src/cmd/nscd/server.c	Fri Feb 12 10:17:43 2010 +0000
@@ -19,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -38,6 +38,7 @@
 #include <tsol/label.h>
 #include <zone.h>
 #include <signal.h>
+#include <sys/resource.h>
 #include "cache.h"
 #include "nscd_log.h"
 #include "nscd_selfcred.h"
@@ -117,6 +118,7 @@
 	char		*ret_locale;
 	char		*ret_textdomain;
 	char		msg[128];
+	struct		rlimit rl;
 
 	ret_locale = setlocale(LC_ALL, "");
 	if (ret_locale == NULL)
@@ -448,6 +450,14 @@
 			(void) dup(0);
 	}
 
+	/* set NOFILE to unlimited */
+	rl.rlim_cur = rl.rlim_max = RLIM_INFINITY;
+	if (setrlimit(RLIMIT_NOFILE, &rl) < 0) {
+		_NSCD_LOG(NSCD_LOG_FRONT_END, NSCD_LOG_LEVEL_ERROR)
+		(me, "Cannot set open file limit: %s\n", strerror(errno));
+		exit(1);
+	}
+
 	/* set up door and establish our own server thread pool */
 	if ((_doorfd = _nscd_setup_server(saved_execname, saved_argv)) == -1) {
 		_NSCD_LOG(NSCD_LOG_FRONT_END, NSCD_LOG_LEVEL_ERROR)
@@ -542,6 +552,7 @@
 	default:
 		exit(0);
 	}
+
 	(void) setsid();
 	(void) open("/dev/null", O_RDWR, 0);
 	(void) dup(0);