/** Argument vector passed to para_server's main function. */
char **argv;
/** The command task structure for scheduling. */
- struct task task;
+ struct task *task;
};
static int want_colors(void)
static void command_pre_select(struct sched *s, struct task *t)
{
- struct server_command_task *sct = container_of(t, struct server_command_task, task);
+ struct server_command_task *sct = task_context(t);
para_fd_set(sct->listen_fd, &s->rfds, &s->max_fileno);
}
static int command_post_select(struct sched *s, struct task *t)
{
- struct server_command_task *sct = container_of(t, struct server_command_task, task);
+ struct server_command_task *sct = task_context(t);
int new_fd, ret, i;
char *peer_name;
*sct = &server_command_task_struct;
PARA_NOTICE_LOG("initializing tcp command socket\n");
- sct->task.pre_select = command_pre_select;
- sct->task.post_select = command_post_select;
sct->argc = argc;
sct->argv = argv;
ret = para_listen_simple(IPPROTO_TCP, conf.port_arg);
if (ret < 0)
goto err;
add_close_on_fork_list(sct->listen_fd); /* child doesn't need the listener */
- sprintf(sct->task.status, "server command task");
- register_task(&sched, &sct->task);
+ sct->task = task_register(&(struct task_info) {
+ .name = "server command",
+ .pre_select = command_pre_select,
+ .post_select = command_post_select,
+ .context = sct,
+ }, &sched);
return;
err:
PARA_EMERG_LOG("%s\n", para_strerror(-ret));
server_init(argc, argv);
mutex_lock(mmd_mutex);
ret = schedule(&sched);
+ sched_shutdown(&sched);
if (ret < 0) {
PARA_EMERG_LOG("%s\n", para_strerror(-ret));
exit(EXIT_FAILURE);