fix FSCORE-82

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7132 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2008-01-07 20:40:59 +00:00
parent 06335ebe76
commit 59ac0a27a2
3 changed files with 41 additions and 35 deletions

View File

@ -1531,6 +1531,7 @@ SWITCH_DECLARE(void) switch_core_memory_reclaim(void);
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);
///\}

View File

@ -430,6 +430,8 @@ int main(int argc, char *argv[])
set_high_priority();
}
switch_core_setrlimits();
#ifndef WIN32
if (runas_user || runas_group) {
if(change_user_group(runas_user, runas_group) < 0) {

View File

@ -661,6 +661,44 @@ static void load_mime_types(void)
}
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_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc
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();