[commit] r7132 - in freeswitch/trunk/src: . include
Author: anthm Date: Mon Jan 7 15:40:59 2008 New Revision: 7132 Modified: freeswitch/trunk/src/include/switch_core.h freeswitch/trunk/src/switch.c freeswitch/trunk/src/switch_core.c Log: fix FSCORE-82 Modified: freeswitch/trunk/src/include/switch_core.h ============================================================================== --- freeswitch/trunk/src/include/switch_core.h (original) +++ freeswitch/trunk/src/include/switch_core.h Mon Jan 7 15:40:59 2008 @@ -1531,6 +1531,7 @@ SWITCH_DECLARE(void) switch_core_memory_reclaim_events(void); SWITCH_DECLARE(void) switch_core_memory_reclaim_logger(void); SWITCH_DECLARE(void) switch_core_memory_reclaim_all(void); +SWITCH_DECLARE(void) switch_core_setrlimits(void); ///\} Modified: freeswitch/trunk/src/switch.c ============================================================================== --- freeswitch/trunk/src/switch.c (original) +++ freeswitch/trunk/src/switch.c Mon Jan 7 15:40:59 2008 @@ -430,6 +430,8 @@ set_high_priority(); } + switch_core_setrlimits(); + #ifndef WIN32 if (runas_user || runas_group) { if(change_user_group(runas_user, runas_group) < 0) { Modified: freeswitch/trunk/src/switch_core.c ============================================================================== --- freeswitch/trunk/src/switch_core.c (original) +++ freeswitch/trunk/src/switch_core.c Mon Jan 7 15:40:59 2008 @@ -661,6 +661,44 @@ } + +SWITCH_DECLARE(void) switch_core_setrlimits(void) +{ +#ifdef HAVE_SETRLIMIT + struct rlimit rlp; + + /* + Setting the stack size on FreeBSD results in an instant crash. + + If anyone knows how to fix this, + feel free to submit a patch to http://jira.freeswitch.org + */ + +#ifndef __FreeBSD__ + memset(&rlp, 0, sizeof(rlp)); + rlp.rlim_cur = SWITCH_THREAD_STACKSIZE; + rlp.rlim_max = SWITCH_THREAD_STACKSIZE; + setrlimit(RLIMIT_STACK, &rlp); +#endif + + 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 + return; +} + + SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switch_bool_t console, const char **err) { switch_xml_t xml = NULL, cfg = NULL; @@ -702,41 +740,6 @@ switch_core_set_variable("base_dir", SWITCH_GLOBAL_dirs.base_dir); -#ifdef HAVE_SETRLIMIT - { - struct rlimit rlp; - - /* - Setting the stack size on FreeBSD results in an instant crash. - - If anyone knows how to fix this, - feel free to submit a patch to http://jira.freeswitch.org - */ - -#ifndef __FreeBSD__ - memset(&rlp, 0, sizeof(rlp)); - rlp.rlim_cur = SWITCH_THREAD_STACKSIZE; - rlp.rlim_max = SWITCH_THREAD_STACKSIZE; - setrlimit(RLIMIT_STACK, &rlp); -#endif - - 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();
participants (1)
-
Freeswitch SVN