struct apr_threadattr_t *myattr = attr;
pthread_attr_getschedparam(&myattr->attr, ¶m);
- param.sched_priority = 50;
+ param.sched_priority = 1;
stat = pthread_attr_setschedparam(&myattr->attr, ¶m);
if (stat == 0) {
switch_assert(SWITCH_GLOBAL_dirs.temp_dir);
}
-SWITCH_DECLARE(int32_t) set_high_priority(void)
+static int32_t set_priority(void)
{
-#ifdef WIN32
- SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
-#else
-
-#ifdef USE_SETRLIMIT
- struct rlimit lim = { RLIM_INFINITY, RLIM_INFINITY };
-#endif
-
#ifdef USE_SCHED_SETSCHEDULER
/*
* Try to use a round-robin scheduler
*/
if (setpriority(PRIO_PROCESS, getpid(), -10) < 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Could not set nice level\n");
+ return -1;
}
#else
if (nice(-10) != -10) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Could not set nice level\n");
+ return -1;
}
#endif
+ return 0;
+}
+
+
+SWITCH_DECLARE(int32_t) set_normal_priority(void)
+{
+ return set_priority();
+}
+
+SWITCH_DECLARE(int32_t) set_high_priority(void)
+{
+ int pri;
+
+#ifdef WIN32
+ SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
+#else
+
+#ifdef USE_SETRLIMIT
+ struct rlimit lim = { RLIM_INFINITY, RLIM_INFINITY };
+#endif
+
+ if ((pri = set_priority())) {
+ return pri;
+ }
+
#ifdef USE_SETRLIMIT
/*
* The amount of memory which can be mlocked is limited for non-root users.