SWITCH_MODULE_RUNTIME_FUNCTION(mod_posix_timer_runtime);
SWITCH_MODULE_DEFINITION(mod_posix_timer, mod_posix_timer_load, mod_posix_timer_shutdown, mod_posix_timer_runtime);
-#define SIG SIGRTMAX
+#define SIG (SIGRTMAX - 1)
#define MAX_INTERVAL 2000 /* ms */
#define TIMERS_PER_INTERVAL 4
#define MAX_ACTIVE_TIMERS 256 /* one byte */
/**
* Load mod_posix_timer and start the runtime thread
*/
-static void load_module()
+static int load_module()
{
fail_count = 0;
warn_count = 0;
session_count = 0;
last_reported_session_count = 0;
shutdown = 0;
- mod_posix_timer_load(&mod, &pool);
+ if (mod_posix_timer_load(&mod, &pool) != SWITCH_STATUS_SUCCESS) {
+ return -1;
+ }
timer_if = mod->timer;
- pthread_create(&module_runtime_thread_id, NULL, module_thread, NULL);
+ return pthread_create(&module_runtime_thread_id, NULL, module_thread, NULL);
}
/**
struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
srand48(ts.tv_nsec);
- load_module();
+ if (load_module() == -1) {
+ return -1;
+ }
//test_timer(20, 5.0f, .2f, 1000);
//test_timer_session(intervals, interval_weights, 4, 2 * 86400.0f, 90, 2000, 30.0, 5.0f);
while(1) {
/* stop periodically to trigger timer shutdown */
- test_timer_session(intervals, interval_weights, 1, 60, 150, 3000, 30.0, 5.0f);
+ test_timer_session(intervals, interval_weights, 1, 60, 150, 190 /* 3000 */, 30.0, 5.0f);
}
//test_timer(1000, 5.0f, 1);
//test_timer(20, 5.0f, .2f, 1000);