提交 90f3ab40 authored 作者: Anthony Minessale's avatar Anthony Minessale

fix thread priority code, this has never worked until today

上级 c7283aaa
Mon Sep 27 13:15:54 CDT 2010 Thu Sep 27 13:36:14 CDT 2012
...@@ -60,6 +60,7 @@ struct apr_thread_t { ...@@ -60,6 +60,7 @@ struct apr_thread_t {
struct apr_threadattr_t { struct apr_threadattr_t {
apr_pool_t *pool; apr_pool_t *pool;
pthread_attr_t attr; pthread_attr_t attr;
int priority;
}; };
struct apr_threadkey_t { struct apr_threadkey_t {
......
...@@ -174,6 +174,11 @@ APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new, ...@@ -174,6 +174,11 @@ APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new,
} }
if ((stat = pthread_create((*new)->td, temp, dummy_worker, (*new))) == 0) { if ((stat = pthread_create((*new)->td, temp, dummy_worker, (*new))) == 0) {
if (attr->priority) {
pthread_t *thread = (*new)->td;
pthread_setschedprio(*thread, attr->priority);
}
return APR_SUCCESS; return APR_SUCCESS;
} }
else { else {
......
...@@ -633,25 +633,16 @@ SWITCH_DECLARE(switch_status_t) switch_threadattr_stacksize_set(switch_threadatt ...@@ -633,25 +633,16 @@ SWITCH_DECLARE(switch_status_t) switch_threadattr_stacksize_set(switch_threadatt
struct apr_threadattr_t { struct apr_threadattr_t {
apr_pool_t *pool; apr_pool_t *pool;
pthread_attr_t attr; pthread_attr_t attr;
int priority;
}; };
#endif #endif
SWITCH_DECLARE(switch_status_t) switch_threadattr_priority_increase(switch_threadattr_t *attr) SWITCH_DECLARE(switch_status_t) switch_threadattr_priority_increase(switch_threadattr_t *attr)
{ {
int stat = 0;
#ifndef WIN32 #ifndef WIN32
struct sched_param param; attr->priority = 10;
struct apr_threadattr_t *myattr = attr;
pthread_attr_getschedparam(&myattr->attr, &param);
param.sched_priority = 1;
stat = pthread_attr_setschedparam(&myattr->attr, &param);
if (stat == 0) {
return SWITCH_STATUS_SUCCESS;
}
#endif #endif
return stat; return SWITCH_STATUS_SUCCESS;
} }
static char TT_KEY[] = "1"; static char TT_KEY[] = "1";
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论