[asterisk-commits] anthonyl: branch anthonyl/7499 r46993 - /team/anthonyl/7499/main/asterisk.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Nov 2 11:30:27 MST 2006


Author: anthonyl
Date: Thu Nov  2 12:30:27 2006
New Revision: 46993

URL: http://svn.digium.com/view/asterisk?rev=46993&view=rev
Log:
7499 patch

Modified:
    team/anthonyl/7499/main/asterisk.c

Modified: team/anthonyl/7499/main/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/anthonyl/7499/main/asterisk.c?rev=46993&r1=46992&r2=46993&view=diff
==============================================================================
--- team/anthonyl/7499/main/asterisk.c (original)
+++ team/anthonyl/7499/main/asterisk.c Thu Nov  2 12:30:27 2006
@@ -1011,6 +1011,28 @@
 	if (n == 0 && option_debug)	
 		printf("Huh?  Child handler, but nobody there?\n");
 	signal(sig, child_handler);
+}
+
+static int set_ulimit(int value)
+{
+	struct rlimit l = { 0, 0};
+
+	if (value <= 0) {
+		ast_log(LOG_WARNING, "Unable to change max files open to invalid value %i\n",value);
+		return 0;
+	}
+	
+	l.rlim_cur = value;
+        l.rlim_max = value;
+
+	if (setrlimit(RLIMIT_NOFILE, &l)) {
+		ast_log(LOG_WARNING, "Unable to disable core size resource limit: %s\n",strerror(errno));
+		return 0;
+	}
+
+	ast_log(LOG_NOTICE, "Setting max files open to %d\n",value);
+	
+	return 0;
 }
 
 /*! \brief Set an X-term or screen title */
@@ -2293,6 +2315,9 @@
 			} else if ((sscanf(v->value, "%lf", &option_maxload) != 1) || (option_maxload < 0.0)) {
 				option_maxload = 0.0;
 			}
+		/* Set the max amount open files */
+		} else if (!strcasecmp(v->name, "maxfiles")) {
+			set_ulimit(atoi(v->value));
 		/* What user to run as */
 		} else if (!strcasecmp(v->name, "runuser")) {
 			ast_copy_string(ast_config_AST_RUN_USER, v->value, sizeof(ast_config_AST_RUN_USER));



More information about the asterisk-commits mailing list