[Freeswitch-svn] [commit] r6864 - freeswitch/trunk/src

Freeswitch SVN anthm at freeswitch.org
Tue Dec 18 11:55:40 EST 2007


Author: anthm
Date: Tue Dec 18 11:55:39 2007
New Revision: 6864

Modified:
   freeswitch/trunk/src/switch.c
   freeswitch/trunk/src/switch_core.c

Log:
add self-adjusting rlimit stuff for systems that support it

Modified: freeswitch/trunk/src/switch.c
==============================================================================
--- freeswitch/trunk/src/switch.c	(original)
+++ freeswitch/trunk/src/switch.c	Tue Dec 18 11:55:39 2007
@@ -235,6 +235,9 @@
 		"\t-g [group]       -- specify group to switch to\n"
 #endif
 		"\t-help            -- this message\n"
+#ifdef HAVE_SETRLIMIT
+		"\t-core            -- dump cores\n"
+#endif
 		"\t-hp              -- enable high priority settings\n"
 		"\t-nosql           -- disable internal sql scoreboard\n"
 		"\t-stop            -- stop freeswitch\n"
@@ -307,6 +310,17 @@
 			known_opt++;
 		}
 #endif
+#ifdef HAVE_SETRLIMIT
+		if (argv[x] && !strcmp(argv[x], "-core")) {
+			struct rlimit rlp;
+			memset(&rlp, 0, sizeof(rlp));
+			rlp.rlim_cur = RLIM_INFINITY;
+			rlp.rlim_max = RLIM_INFINITY;
+			setrlimit(RLIMIT_CORE, &rlp);
+			known_opt++;
+		}
+#endif
+
 		if (argv[x] && !strcmp(argv[x], "-hp")) {
 			high_prio++;
 			known_opt++;

Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c	(original)
+++ freeswitch/trunk/src/switch_core.c	Tue Dec 18 11:55:39 2007
@@ -36,6 +36,7 @@
 #include <switch.h>
 #include <switch_version.h>
 #include "private/switch_core_pvt.h"
+#include <switch_private.h>
 
 SWITCH_DECLARE_DATA switch_directories SWITCH_GLOBAL_dirs = { 0 };
 
@@ -683,6 +684,33 @@
 	switch_core_set_variable("base_dir", SWITCH_GLOBAL_dirs.base_dir);
 	
 
+#ifdef HAVE_SETRLIMIT
+	{
+		struct rlimit rlp;
+
+		memset(&rlp, 0, sizeof(rlp));
+		rlp.rlim_cur = SWITCH_THREAD_STACKSIZE;
+		rlp.rlim_max = SWITCH_THREAD_STACKSIZE;
+		setrlimit(RLIMIT_STACK, &rlp);
+
+		memset(&rlp, 0, sizeof(rlp));
+		rlp.rlim_cur = 999999;
+		rlp.rlim_max = 999999;
+		setrlimit(RLIMIT_NOFILE, &rlp);
+
+		memset(&rlp, 0, sizeof(rlp));
+		rlp.rlim_cur = RLIM_INFINITY;
+		rlp.rlim_max = RLIM_INFINITY;
+
+		setrlimit(RLIMIT_CPU, &rlp);
+		setrlimit(RLIMIT_DATA, &rlp);
+		setrlimit(RLIMIT_FSIZE, &rlp);
+		setrlimit(RLIMIT_AS, &rlp);
+	}
+	
+#endif
+
+
 	if (switch_xml_init(runtime.memory_pool, err) != SWITCH_STATUS_SUCCESS) {
 		apr_terminate();
 		return SWITCH_STATUS_MEMERR;
@@ -712,6 +740,15 @@
 	                    switch_core_session_ctl(SCSC_LOGLEVEL, &level);
 					}
 					
+#ifdef HAVE_SETRLIMIT
+				} else if (!strcasecmp(var, "dump-cores")) {
+					struct rlimit rlp;
+					memset(&rlp, 0, sizeof(rlp));
+					rlp.rlim_cur = RLIM_INFINITY;
+					rlp.rlim_max = RLIM_INFINITY;
+					setrlimit(RLIMIT_CORE, &rlp);
+#endif
+
 				} else if (!strcasecmp(var, "mailer-app")) {
 					runtime.mailer_app = switch_core_strdup(runtime.memory_pool, val);
 				} else if (!strcasecmp(var, "mailer-app-args")) {



More information about the Freeswitch-svn mailing list