static void shuffle(char **base, size_t num)
{
- srandom(now->tv_sec);
+ srandom(time(NULL));
qsort(base, num, sizeof(char *), shuffle_compare);
}
filter_init();
writer_init();
- clock_get_realtime(now);
sched.default_timeout.tv_sec = 5;
parse_config_or_die(argc, argv);
};
static struct timeval now_struct;
-struct timeval *now = &now_struct;
+const struct timeval *now = &now_struct;
static inline bool timeout_is_zero(struct sched *s)
{
FD_ZERO(&s->wfds);
s->select_timeout = s->default_timeout;
s->max_fileno = -1;
- clock_get_realtime(now);
+ clock_get_realtime(&now_struct);
sched_preselect(s);
ret = s->select_function(s->max_fileno + 1, &s->rfds, &s->wfds,
&s->select_timeout);
FD_ZERO(&s->rfds);
FD_ZERO(&s->wfds);
}
- clock_get_realtime(now);
+ clock_get_realtime(&now_struct);
num_running_tasks = sched_post_select(s);
if (num_running_tasks == 0)
return 0;
* scheduler are allowed to block, this value should be accurate enough so that
* there is no need to call clock_gettime() directly.
*/
-extern struct timeval *now;
+extern const struct timeval *now;
struct task *task_register(struct task_info *info, struct sched *s);
int schedule(struct sched *s);