]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
enable optimal defaults on linux kernels that can support newer features.
authorAnthony Minessale <anthm@freeswitch.org>
Mon, 18 Apr 2011 11:17:33 +0000 (11:17 +0000)
committerAnthony Minessale <anthm@freeswitch.org>
Mon, 18 Apr 2011 11:17:33 +0000 (11:17 +0000)
src/switch_core.c
src/switch_time.c

index 1e91279091084d667cba54f9ceb64df16a634f29..ef5d1c497dae4bd0b1e0abe602128737c3517781 100644 (file)
@@ -1662,9 +1662,6 @@ static void switch_load_core_config(const char *file)
                                        switch_time_set_monotonic(switch_true(val));
                                } else if (!strcasecmp(var, "enable-softtimer-timerfd")) {
                                        switch_time_set_timerfd(switch_true(val));
-                                       if (switch_true(val)) {
-                                               switch_clear_flag((&runtime), SCF_CALIBRATE_CLOCK);
-                                       }
                                } else if (!strcasecmp(var, "enable-clock-nanosleep")) {
                                        switch_time_set_nanosleep(switch_true(val));
                                } else if (!strcasecmp(var, "enable-cond-yield")) {
index d6aa8c8b08d732966c820bc138703079ceb1b7bb..9ec902f4d7a17412bdef06a2bd0aba2a355e8b7c 100644 (file)
@@ -61,14 +61,20 @@ static int MONO = 1;
 static int MONO = 0;
 #endif
 
+/* clock_nanosleep works badly on some kernels but really well on others.
+   timerfd seems to work well as long as it exists so if you have timerfd we'll also enable clock_nanosleep by default.
+*/
 #if defined(HAVE_TIMERFD_CREATE)
-// We'll default this to 1 after we have had some positive feedback that it works well
-static int TFD = 0;
+static int TFD = 1;
+#if defined(HAVE_CLOCK_NANOSLEEP)
+static int NANO = 1;
 #else
-static int TFD = 0;
+static int NANO = 0;
 #endif
-
+#else
+static int TFD = 0;
 static int NANO = 0;
+#endif
 
 static int OFFSET = 0;
 
@@ -326,6 +332,7 @@ SWITCH_DECLARE(void) switch_time_set_timerfd(switch_bool_t enable)
 #if defined(HAVE_TIMERFD_CREATE)
        TFD = enable ? 1 : 0;
        switch_time_sync();
+
 #else
        TFD = 0;
 #endif
@@ -1116,6 +1123,10 @@ SWITCH_MODULE_LOAD_FUNCTION(softtimer_load)
                switch_time_set_cond_yield(SWITCH_FALSE);
        }
 
+       if (TFD) {
+               switch_clear_flag((&runtime), SCF_CALIBRATE_CLOCK);
+       }
+
        if (switch_test_flag((&runtime), SCF_CALIBRATE_CLOCK)) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Calibrating timer, please wait...\n");
                switch_time_calibrate_clock();