static void signal_pre_select(struct sched *s, struct task *t)
{
- struct signal_task *st = container_of(t, struct signal_task, task);
+ struct signal_task *st = task_context(t);
para_fd_set(st->fd, &s->rfds, &s->max_fileno);
}
para_install_sighandler(SIGTERM);
para_install_sighandler(SIGHUP);
- st->task.pre_select = signal_pre_select;
- st->task.post_select = afs_signal_post_select;
- sprintf(st->task.status, "signal task");
- register_task(s, &st->task);
+ st->task = task_register(&(struct task_info) {
+ .name = "signal",
+ .pre_select = signal_pre_select,
+ .post_select = afs_signal_post_select,
+ .context = st,
+
+ }, s);
}
static struct list_head afs_client_list;
static void signal_pre_select(struct sched *s, struct task *t)
{
- struct signal_task *st = container_of(t, struct signal_task, task);
+ struct signal_task *st = task_context(t);
para_fd_set(st->fd, &s->rfds, &s->max_fileno);
}
return 0;
}
-static void signal_setup_default(struct signal_task *st)
-{
- st->task.pre_select = signal_pre_select;
- st->task.post_select = signal_post_select;
- sprintf(st->task.status, "signal task");
-}
-
static void command_pre_select(struct sched *s, struct task *t)
{
struct command_task *ct = container_of(t, struct command_task, task);
FOR_EACH_SLOT(i)
clear_slot(i);
setup_signal_handling();
- signal_setup_default(sig_task);
init_status_task(stat_task);
init_command_task(cmd_task);
if (conf.daemon_given)
daemonize(false /* parent exits immediately */);
- register_task(&sched, &sig_task->task);
+ sig_task->task = task_register(&(struct task_info) {
+ .name = "signal",
+ .pre_select = signal_pre_select,
+ .post_select = signal_post_select,
+ .context = sig_task,
+ }, &sched);
register_task(&sched, &cmd_task->task);
register_task(&sched, &stat_task->task);
sched.default_timeout.tv_sec = 2;
static void signal_pre_select(struct sched *s, struct task *t)
{
- struct signal_task *st = container_of(t, struct signal_task, task);
+ struct signal_task *st = task_context(t);
para_fd_set(st->fd, &s->rfds, &s->max_fileno);
}
static struct signal_task signal_task_struct,
*st = &signal_task_struct;
- st->task.pre_select = signal_pre_select;
- st->task.post_select = signal_post_select;
- sprintf(st->task.status, "signal task");
-
PARA_NOTICE_LOG("setting up signal handling\n");
st->fd = para_signal_init(); /* always successful */
para_install_sighandler(SIGINT);
para_install_sighandler(SIGCHLD);
para_sigaction(SIGPIPE, SIG_IGN);
add_close_on_fork_list(st->fd);
- register_task(&sched, &st->task);
+ st->task = task_register(&(struct task_info) {
+ .name = "signal",
+ .pre_select = signal_pre_select,
+ .post_select = signal_post_select,
+ .context = st,
+
+ }, &sched);
}
static void command_pre_select(struct sched *s, struct task *t)
/** The signal pipe. */
int fd;
/** The associated task structure. */
- struct task task;
+ struct task *task;
};
int para_signal_init(void);