提交 6627dc86 authored 作者: Anthony Minessale's avatar Anthony Minessale

fix some contention issues under really high load...That doesn't mean you need…

fix some contention issues under really high load...That doesn't mean you need to push it this hard and bug me about it =p
上级 0160072a
......@@ -577,7 +577,7 @@ AX_HAVE_CPU_SET
AC_CHECK_LIB(rt, clock_gettime, [AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if you have clock_gettime()])])
AC_CHECK_LIB(rt, clock_getres, [AC_DEFINE(HAVE_CLOCK_GETRES, 1, [Define if you have clock_getres()])])
AC_CHECK_LIB(rt, clock_nanosleep, [AC_DEFINE(HAVE_CLOCK_NANOSLEEP, 1, [Define if you have clock_nanosleep()])])
AC_CHECK_LIB(pthread, pthread_setschedprio, [AC_DEFINE(HAVE_PTHREAD_SETSCHEDPRIO, 1, [Define if you have pthread_setschedprio()])])
AC_CHECK_LIB(pthread, pthread_setschedparam, [AC_DEFINE(HAVE_PTHREAD_SETSCHEDPARAM, 1, [Define if you have pthread_setschedparam()])])
AC_CHECK_FUNC(socket, , AC_CHECK_LIB(socket, socket))
......
Tue Oct 23 13:13:30 EDT 2012
Wed Nov 7 10:37:54 CST 2012
......@@ -1620,7 +1620,7 @@ APR_CHECK_DEFINE_FILES(POLLIN, poll.h sys/poll.h)
if test "$threads" = "1"; then
APR_CHECK_DEFINE(PTHREAD_PROCESS_SHARED, pthread.h)
AC_CHECK_FUNCS(pthread_mutexattr_setpshared)
AC_CHECK_LIB(pthread, pthread_setschedprio, [AC_DEFINE(HAVE_PTHREAD_SETSCHEDPRIO, 1, [Define if you have pthread_setschedprio()])])
AC_CHECK_LIB(pthread, pthread_setschedparam, [AC_DEFINE(HAVE_PTHREAD_SETSCHEDPARAM, 1, [Define if you have pthread_setschedparam()])])
# Some systems have setpshared and define PROCESS_SHARED, but don't
# really support PROCESS_SHARED locks. So, we must validate that we
......
......@@ -146,6 +146,7 @@ APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new,
{
apr_status_t stat;
pthread_attr_t *temp;
pthread_t tt;
(*new) = (apr_thread_t *)apr_pcalloc(pool, sizeof(apr_thread_t));
......@@ -173,15 +174,21 @@ APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new,
return stat;
}
if ((stat = pthread_create((*new)->td, temp, dummy_worker, (*new))) == 0) {
if ((stat = pthread_create(&tt, temp, dummy_worker, (*new))) == 0) {
#ifdef HAVE_PTHREAD_SETSCHEDPRIO
#ifdef HAVE_PTHREAD_SETSCHEDPARAM
if (attr && attr->priority) {
pthread_t *thread = (*new)->td;
pthread_setschedprio(*thread, attr->priority);
int policy;
struct sched_param param = { 0 };
pthread_getschedparam(tt, &policy, &param);
param.sched_priority = attr->priority;
pthread_setschedparam(tt, policy, &param);
}
#endif
*(*new)->td = tt;
return APR_SUCCESS;
}
else {
......
Fri Nov 2 13:36:06 CDT 2012
Wed Nov 7 10:37:42 CST 2012
......@@ -254,7 +254,7 @@ if test x"$have_check" = "xyes"; then
fi
AC_CHECK_HEADERS([fnmatch.h])
AC_CHECK_LIB(pthread, pthread_setschedprio, [AC_DEFINE(HAVE_PTHREAD_SETSCHEDPRIO, 1, [Define if you have pthread_setschedprio()])])
AC_CHECK_LIB(pthread, pthread_setschedparam, [AC_DEFINE(HAVE_PTHREAD_SETSCHEDPARAM, 1, [Define if you have pthread_setschedparam()])])
dnl dl is currently used only in testing
......
......@@ -268,9 +268,13 @@ int su_pthreaded_port_start(su_port_create_f *create,
pthread_mutex_lock(arg.mutex);
if (pthread_create(&tid, &attr, su_pthread_port_clone_main, &arg) == 0) {
#ifdef HAVE_PTHREAD_SETSCHEDPARAM
int policy;
struct sched_param param;
#ifdef HAVE_PTHREAD_SETSCHEDPRIO
pthread_setschedprio(tid, 99);
pthread_getschedparam(tid, &policy, &param);
param.sched_priority = 99;
pthread_setschedparam(tid, policy, &param);
#endif
pthread_cond_wait(arg.cv, arg.mutex);
......
......@@ -6532,6 +6532,9 @@ char *sofia_glue_execute_sql2str(sofia_profile_t *profile, switch_mutex_t *mutex
switch_cache_db_release_db_handle(&dbh);
sofia_glue_fire_events(profile);
return ret;
}
......@@ -7159,6 +7162,23 @@ void sofia_event_fire(sofia_profile_t *profile, switch_event_t **event)
*event = NULL;
}
void sofia_glue_fire_events(sofia_profile_t *profile)
{
void *pop = NULL;
while (profile->event_queue && switch_queue_trypop(profile->event_queue, &pop) == SWITCH_STATUS_SUCCESS && pop) {
switch_event_t *event = (switch_event_t *) pop;
switch_event_fire(&event);
}
}
void sofia_event_fire(sofia_profile_t *profile, switch_event_t **event)
{
switch_queue_push(profile->event_queue, *event);
*event = NULL;
}
/* For Emacs:
* Local Variables:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论