]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
improve some defaults to tune performance if you use -heavy_timer, try not using it
authorAnthony Minessale <anthm@freeswitch.org>
Tue, 22 Mar 2011 18:27:37 +0000 (13:27 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Tue, 22 Mar 2011 18:27:37 +0000 (13:27 -0500)
src/include/switch_core.h
src/switch.c
src/switch_apr.c
src/switch_core.c

index 37c672334f6a199c9b196f0e81b4c6b76fc62cc6..e54de72027ce7cb43901f15f3b3de1de29c68f6f 100644 (file)
@@ -1940,6 +1940,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_management_exec(char *relative_oid,
   \return 0 on success
 */
 SWITCH_DECLARE(int32_t) set_high_priority(void);
+SWITCH_DECLARE(int32_t) set_normal_priority(void);
 
 /*! 
   \brief Change user and/or group of the running process
index 33e7fb633678ecd820045421e71ed87a32b6fba2..ad9cdf8e6ed54859d347eafd86361509ba70295b 100644 (file)
@@ -824,6 +824,8 @@ int main(int argc, char *argv[])
 
        if (high_prio) {
                set_high_priority();
+       } else {
+               set_normal_priority();
        }
 
        switch_core_setrlimits();
index 3ca3c63f77c05993eea600a781d5111bd0fa0ba6..495e0605a814f8a64480908451ee56b274c95af8 100644 (file)
@@ -630,7 +630,7 @@ SWITCH_DECLARE(switch_status_t) switch_threadattr_priority_increase(switch_threa
        struct apr_threadattr_t *myattr = attr;
 
        pthread_attr_getschedparam(&myattr->attr, &param);
-       param.sched_priority = 50;
+       param.sched_priority = 1;
        stat = pthread_attr_setschedparam(&myattr->attr, &param);
 
        if (stat == 0) {
index 03b3d1c8d09d1c589c21a263e0b04305b26c0c0c..87bea3077706bac69dc147699e2063a5f109ccc9 100644 (file)
@@ -606,16 +606,8 @@ SWITCH_DECLARE(void) switch_core_set_globals(void)
        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
@@ -637,13 +629,40 @@ SWITCH_DECLARE(int32_t) set_high_priority(void)
         */
        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.