The timeval structure pointed to by the public now pointer should not
be modified outside sched.c. Fortunately play.c is the only place
which violates this rule. This patch fixes up play.c and marks the
pointer as const.
static void shuffle(char **base, size_t num)
{
static void shuffle(char **base, size_t num)
{
qsort(base, num, sizeof(char *), shuffle_compare);
}
qsort(base, num, sizeof(char *), shuffle_compare);
}
filter_init();
writer_init();
filter_init();
writer_init();
- clock_get_realtime(now);
sched.default_timeout.tv_sec = 5;
parse_config_or_die(argc, argv);
sched.default_timeout.tv_sec = 5;
parse_config_or_die(argc, argv);
};
static struct timeval now_struct;
};
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)
{
static inline bool timeout_is_zero(struct sched *s)
{
FD_ZERO(&s->wfds);
s->select_timeout = s->default_timeout;
s->max_fileno = -1;
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);
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);
}
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;
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.
*/
* 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);
struct task *task_register(struct task_info *info, struct sched *s);
int schedule(struct sched *s);