few new command line opts -vm for conditonal timer, -nocal to skip timer calibration and -nort to turn off clock_realtime fam of functions
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16324 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
2731b1e580
commit
da29b01195
|
@ -242,7 +242,10 @@ typedef enum {
|
||||||
SCF_RESTART = (1 << 4),
|
SCF_RESTART = (1 << 4),
|
||||||
SCF_SHUTDOWN_REQUESTED = (1 << 5),
|
SCF_SHUTDOWN_REQUESTED = (1 << 5),
|
||||||
SCF_USE_AUTO_NAT = (1 << 6),
|
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;
|
} switch_core_flag_enum_t;
|
||||||
typedef uint32_t switch_core_flag_t;
|
typedef uint32_t switch_core_flag_t;
|
||||||
|
|
||||||
|
|
22
src/switch.c
22
src/switch.c
|
@ -171,7 +171,7 @@ void WINAPI ServiceCtrlHandler(DWORD control)
|
||||||
/* the main service entry point */
|
/* the main service entry point */
|
||||||
void WINAPI service_main(DWORD numArgs, char **args)
|
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 */
|
const char *err = NULL; /* error value for return from freeswitch initialization */
|
||||||
/* we have to initialize the service-specific stuff */
|
/* we have to initialize the service-specific stuff */
|
||||||
memset(&status, 0, sizeof(SERVICE_STATUS));
|
memset(&status, 0, sizeof(SERVICE_STATUS));
|
||||||
|
@ -282,7 +282,7 @@ int main(int argc, char *argv[])
|
||||||
#ifdef __sun
|
#ifdef __sun
|
||||||
switch_core_flag_t flags = SCF_USE_SQL;
|
switch_core_flag_t flags = SCF_USE_SQL;
|
||||||
#else
|
#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
|
#endif
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
switch_status_t destroy_status;
|
switch_status_t destroy_status;
|
||||||
|
@ -328,7 +328,10 @@ int main(int argc, char *argv[])
|
||||||
"\t-hp -- enable high priority settings\n"
|
"\t-hp -- enable high priority settings\n"
|
||||||
"\t-vg -- run under valgrind\n"
|
"\t-vg -- run under valgrind\n"
|
||||||
"\t-nosql -- disable internal sql scoreboard\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-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-stop -- stop freeswitch\n"
|
||||||
"\t-nc -- do not output to a console and background\n"
|
"\t-nc -- do not output to a console and background\n"
|
||||||
"\t-c -- output to a console and stay in the foreground\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++;
|
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")) {
|
if (local_argv[x] && !strcmp(local_argv[x], "-vg")) {
|
||||||
flags |= SCF_VG;
|
flags |= SCF_VG;
|
||||||
known_opt++;
|
known_opt++;
|
||||||
|
|
|
@ -198,7 +198,7 @@ SWITCH_DECLARE(void) switch_time_calibrate_clock(void)
|
||||||
|
|
||||||
OFFSET = 0;
|
OFFSET = 0;
|
||||||
|
|
||||||
for (x = 0; x < 500; x++) {
|
for (x = 0; x < 100; x++) {
|
||||||
avg = average_time(val, 50);
|
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);
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (good >= 10) {
|
||||||
OFFSET = (int)(want - val);
|
OFFSET = (int)(want - val);
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Timer offset of %d calculated\n", OFFSET);
|
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_check = timer_check;
|
||||||
timer_interface->timer_destroy = timer_destroy;
|
timer_interface->timer_destroy = timer_destroy;
|
||||||
|
|
||||||
|
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_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Calibrating timer, please wait...\n");
|
||||||
switch_time_calibrate_clock();
|
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 */
|
/* indicate that the module should continue to be loaded */
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
|
Loading…
Reference in New Issue