]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
few new command line opts -vm for conditonal timer, -nocal to skip timer calibration...
authorAnthony Minessale <anthony.minessale@gmail.com>
Fri, 15 Jan 2010 21:09:51 +0000 (21:09 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Fri, 15 Jan 2010 21:09:51 +0000 (21:09 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16324 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_types.h
src/switch.c
src/switch_time.c

index d664aa8030e803ad66a7567d8848778504cffc48..309c00eade26330672433d6f33d1a2d9786ff3cb 100644 (file)
@@ -242,7 +242,10 @@ typedef enum {
        SCF_RESTART = (1 << 4),
        SCF_SHUTDOWN_REQUESTED = (1 << 5),
        SCF_USE_AUTO_NAT = (1 << 6),
-       SCF_EARLY_HANGUP = (1 << 7)
+       SCF_EARLY_HANGUP = (1 << 7),
+       SCF_CALIBRATE_CLOCK = (1 << 8),
+       SCF_USE_COND_TIMING = (1 << 9),
+       SCF_USE_CLOCK_RT = (1 << 10)
 } switch_core_flag_enum_t;
 typedef uint32_t switch_core_flag_t;
 
index 00a884b31631d58d58ea4dda9395bb8b0127169d..a07101e41b8278e1551940c45ed052481d85898b 100644 (file)
@@ -171,7 +171,7 @@ void WINAPI ServiceCtrlHandler(DWORD control)
 /* the main service entry point */
 void WINAPI service_main(DWORD numArgs, char **args)
 {
-       switch_core_flag_t flags = SCF_USE_SQL | SCF_USE_AUTO_NAT;
+       switch_core_flag_t flags = SCF_USE_SQL | SCF_USE_AUTO_NAT | SCF_CALIBRATE_CLOCK | SCF_USE_CLOCK_RT;
        const char *err = NULL;         /* error value for return from freeswitch initialization */
        /*  we have to initialize the service-specific stuff */
        memset(&status, 0, sizeof(SERVICE_STATUS));
@@ -282,7 +282,7 @@ int main(int argc, char *argv[])
 #ifdef __sun
        switch_core_flag_t flags = SCF_USE_SQL;
 #else
-       switch_core_flag_t flags = SCF_USE_SQL | SCF_USE_AUTO_NAT;
+       switch_core_flag_t flags = SCF_USE_SQL | SCF_USE_AUTO_NAT | SCF_CALIBRATE_CLOCK | SCF_USE_CLOCK_RT;
 #endif
        int ret = 0;
        switch_status_t destroy_status;
@@ -328,7 +328,10 @@ int main(int argc, char *argv[])
                "\t-hp                    -- enable high priority settings\n"
                "\t-vg                    -- run under valgrind\n"
                "\t-nosql                 -- disable internal sql scoreboard\n"
+               "\t-vm                    -- use possibly more vm-friendly timing code.\n"
                "\t-nonat                 -- disable auto nat detection\n"
+               "\t-nocal                 -- disable clock calibration\n"
+               "\t-nort                  -- disable clock clock_realtime\n"
                "\t-stop                  -- stop freeswitch\n"
                "\t-nc                    -- do not output to a console and background\n"
                "\t-c                     -- output to a console and stay in the foreground\n"
@@ -492,6 +495,21 @@ int main(int argc, char *argv[])
                        known_opt++;
                }
 
+               if (local_argv[x] && !strcmp(local_argv[x], "-vm")) {
+                       flags |= SCF_USE_COND_TIMING;
+                       known_opt++;
+               }
+
+               if (local_argv[x] && !strcmp(local_argv[x], "-nort")) {
+                       flags &= ~SCF_USE_CLOCK_RT;
+                       known_opt++;
+               }
+
+               if (local_argv[x] && !strcmp(local_argv[x], "-nocal")) {
+                       flags &= ~SCF_CALIBRATE_CLOCK;
+                       known_opt++;
+               }
+
                if (local_argv[x] && !strcmp(local_argv[x], "-vg")) {
                        flags |= SCF_VG;
                        known_opt++;
index cfc052e1aeff2435445a7b564db70f8178836d69..c3e0dd3c12eae71afba84550c6b5c995ad9196ec 100644 (file)
@@ -198,7 +198,7 @@ SWITCH_DECLARE(void) switch_time_calibrate_clock(void)
 
        OFFSET = 0;
        
-       for (x = 0; x < 500; x++) {
+       for (x = 0; x < 100; x++) {
                avg = average_time(val, 50);
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Test: %ld Average: %ld Step: %d\n", (long)val, (long)avg, step);
 
@@ -231,8 +231,12 @@ SWITCH_DECLARE(void) switch_time_calibrate_clock(void)
                }
        }
 
-       OFFSET = (int)(want - val);
-       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Timer offset of %d calculated\n", OFFSET);
+       if (good >= 10) {
+               OFFSET = (int)(want - val);
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Timer offset of %d calculated\n", OFFSET);
+       } else {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Timer offset of NOT calculated\n");
+       }
 }
 
 
@@ -943,8 +947,20 @@ SWITCH_MODULE_LOAD_FUNCTION(softtimer_load)
        timer_interface->timer_check = timer_check;
        timer_interface->timer_destroy = timer_destroy;
 
-       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Calibrating timer, please wait...\n");
-       switch_time_calibrate_clock();
+       if (!switch_test_flag((&runtime), SCF_USE_CLOCK_RT)) {
+               switch_time_set_nanosleep(SWITCH_FALSE);
+       }
+       
+       if (!switch_test_flag((&runtime), SCF_USE_COND_TIMING)) {
+               switch_time_set_cond_yield(SWITCH_TRUE);
+       }
+
+       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();
+       } else {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Clock calibration disabled.\n");
+       }
 
        /* indicate that the module should continue to be loaded */
        return SWITCH_STATUS_SUCCESS;