update_master_clock_info(0, NULL, 0, 0, 0);
}
if (timing_peer_count == 0)
- debug(2, "No timing peer list found");
+ debug(2, "no valid qualified clocks ");
else
- debug(1, "No master clock not found!");
+ debug(1, "no master clock!");
} else {
// we found a master clock
if (old_master != best_so_far) {
- // if the naster is a new one
+ // if the master is a new one
clocks_private[best_so_far].flags |= (1 << clock_is_becoming_master);
} else {
- // if its the same one as before
+ // if it's the same one as before
clocks_private[best_so_far].flags |= (1 << clock_is_master);
}
}
int master_clock_index = -1;
+typedef struct {
+ uint64_t trigger_time;
+ uint64_t (*task)(uint64_t nominal_call_time, void * private_data);
+} timed_task_t;
+
+#define TIMED_TASKS 2
+
+timed_task_t timed_tasks[TIMED_TASKS];
+
+
+uint64_t sample_task(uint64_t call_time, void *private_data) {
+ int *i = (int *)private_data;
+ debug(1,"sample_task %d called.", *i);
+ uint64_t next_time = call_time;
+ next_time = next_time + 1000000000;
+ return next_time;
+}
+
struct shm_structure *shared_memory = NULL; // this is where public clock info is available
int epoll_fd;
if (err != 0) {
die("mutex initialization failed - %s.", strerror(errno));
}
+
+ // start the timed tasks
+
+ timed_tasks[0].trigger_time = get_time_now() + 1000000000;
+ timed_tasks[0].task = sample_task;
+ timed_tasks[1].trigger_time = get_time_now() + 10000000000;
+ timed_tasks[1].task = sample_task;
// now, get down to business
if (sockets_open_stuff.sockets_open > 0) {
}
if (retval >= 0)
manage_clock_sources(reception_time, (clock_source_private_data *)&clocks_private);
+ int i;
+ for (i = 0; i<TIMED_TASKS; i++) {
+ if (timed_tasks[i].trigger_time != 0) {
+ int64_t time_to_wait = timed_tasks[i].trigger_time - reception_time;
+ if (time_to_wait <= 0) {
+ debug(1,"repetitive task %d called now.", i);
+ timed_tasks[i].trigger_time = timed_tasks[i].task(reception_time,(void *)&i);
+ }
+ }
+ }
}
}
// should never get to here, unless no sockets were ever opened.