git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12568 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2009-03-11 15:57:42 +00:00
parent 377449cc9f
commit 83903d5938
1 changed files with 19 additions and 20 deletions

View File

@ -42,7 +42,6 @@
#include <sys/resource.h> #include <sys/resource.h>
#endif #endif
#endif #endif
#include <errno.h>
SWITCH_DECLARE_DATA switch_directories SWITCH_GLOBAL_dirs = { 0 }; SWITCH_DECLARE_DATA switch_directories SWITCH_GLOBAL_dirs = { 0 };
@ -793,7 +792,7 @@ SWITCH_DECLARE(void) switch_core_setrlimits(void)
#ifndef __FreeBSD__ #ifndef __FreeBSD__
memset(&rlp, 0, sizeof(rlp)); memset(&rlp, 0, sizeof(rlp));
rlp.rlim_cur = SWITCH_THREAD_STACKSIZE; rlp.rlim_cur = SWITCH_THREAD_STACKSIZE;
rlp.rlim_max = SWITCH_THREAD_STACKSIZE; rlp.rlim_max = SWITCH_SYSTEM_THREAD_STACKSIZE;
setrlimit(RLIMIT_STACK, &rlp); setrlimit(RLIMIT_STACK, &rlp);
#endif #endif
@ -1590,27 +1589,9 @@ struct system_thread_handle {
static void *SWITCH_THREAD_FUNC system_thread(switch_thread_t *thread, void *obj) static void *SWITCH_THREAD_FUNC system_thread(switch_thread_t *thread, void *obj)
{ {
struct system_thread_handle *sth = (struct system_thread_handle *)obj; struct system_thread_handle *sth = (struct system_thread_handle *)obj;
#if defined(HAVE_SETRLIMIT) && !defined(__FreeBSD__)
struct rlimit rlim;
rlim.rlim_cur = SWITCH_SYSTEM_THREAD_STACKSIZE;
rlim.rlim_max = SWITCH_SYSTEM_THREAD_STACKSIZE;
if (setrlimit(RLIMIT_STACK, &rlim) < 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Setting stack size failed! (%s)\n", strerror(errno));
}
#endif
sth->ret = system(sth->cmd); sth->ret = system(sth->cmd);
#if defined(HAVE_SETRLIMIT) && !defined(__FreeBSD__)
rlim.rlim_cur = SWITCH_THREAD_STACKSIZE;
rlim.rlim_max = SWITCH_SYSTEM_THREAD_STACKSIZE;
if (setrlimit(RLIMIT_STACK, &rlim) < 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Setting stack size failed! (%s)\n", strerror(errno));
}
#endif
switch_mutex_lock(sth->mutex); switch_mutex_lock(sth->mutex);
switch_thread_cond_signal(sth->cond); switch_thread_cond_signal(sth->cond);
switch_mutex_unlock(sth->mutex); switch_mutex_unlock(sth->mutex);
@ -1627,6 +1608,15 @@ SWITCH_DECLARE(int) switch_system(const char *cmd, switch_bool_t wait)
int ret = 0; int ret = 0;
struct system_thread_handle *sth; struct system_thread_handle *sth;
switch_memory_pool_t *pool; switch_memory_pool_t *pool;
#if defined(HAVE_SETRLIMIT) && !defined(__FreeBSD__)
struct rlimit rlim;
rlim.rlim_cur = SWITCH_SYSTEM_THREAD_STACKSIZE;
rlim.rlim_max = SWITCH_SYSTEM_THREAD_STACKSIZE;
if (setrlimit(RLIMIT_STACK, &rlim) < 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Setting stack size failed!\n");
}
#endif
if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) { if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
@ -1650,6 +1640,15 @@ SWITCH_DECLARE(int) switch_system(const char *cmd, switch_bool_t wait)
switch_threadattr_detach_set(thd_attr, 1); switch_threadattr_detach_set(thd_attr, 1);
switch_thread_create(&thread, thd_attr, system_thread, sth, sth->pool); switch_thread_create(&thread, thd_attr, system_thread, sth, sth->pool);
#if defined(HAVE_SETRLIMIT) && !defined(__FreeBSD__)
rlim.rlim_cur = SWITCH_THREAD_STACKSIZE;
rlim.rlim_max = SWITCH_THREAD_STACKSIZE;
if (setrlimit(RLIMIT_STACK, &rlim) < 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Setting stack size failed!\n");
}
#endif
if (wait) { if (wait) {
switch_thread_cond_wait(sth->cond, sth->mutex); switch_thread_cond_wait(sth->cond, sth->mutex);
ret = sth->ret; ret = sth->ret;