X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=afs.c;h=68afec6c1c3a0a8b0b58b5ec74993dffa73e314c;hp=135888a7fc632e6760d2aba4e1b4b2b4738af618;hb=3a6b996d8b39fdc067df352d1eee757ef2a8f49b;hpb=d87806284b9f6be9aab71ccbf0280d273b57eeb3 diff --git a/afs.c b/afs.c index 135888a7..68afec6c 100644 --- a/afs.c +++ b/afs.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2013 Andre Noll + * Copyright (C) 2007-2014 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -81,7 +81,7 @@ struct command_task { */ uint32_t cookie; /** The associated task structure. */ - struct task task; + struct task *task; }; extern int mmd_mutex; @@ -719,13 +719,13 @@ static int open_afs_tables(void) return ret; } -static void signal_pre_select(struct sched *s, struct task *t) +static void signal_pre_select(struct sched *s, void *context) { - struct signal_task *st = container_of(t, struct signal_task, task); + struct signal_task *st = context; para_fd_set(st->fd, &s->rfds, &s->max_fileno); } -static int afs_signal_post_select(struct sched *s, __a_unused struct task *t) +static int afs_signal_post_select(struct sched *s, __a_unused void *context) { int signum, ret; @@ -762,15 +762,18 @@ static void register_signal_task(struct sched *s) 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; -/** Describes on connected afs client. */ +/** Describes one connected afs client. */ struct afs_client { /** Position in the afs client list. */ struct list_head node; @@ -780,9 +783,9 @@ struct afs_client { struct timeval connect_time; }; -static void command_pre_select(struct sched *s, struct task *t) +static void command_pre_select(struct sched *s, void *context) { - struct command_task *ct = container_of(t, struct command_task, task); + struct command_task *ct = context; struct afs_client *client; para_fd_set(server_socket, &s->rfds, &s->max_fileno); @@ -917,14 +920,14 @@ err: /** Shutdown connection if query has not arrived until this many seconds. */ #define AFS_CLIENT_TIMEOUT 3 -static int command_post_select(struct sched *s, struct task *t) +static int command_post_select(struct sched *s, void *context) { - struct command_task *ct = container_of(t, struct command_task, task); + struct command_task *ct = context; struct sockaddr_un unix_addr; struct afs_client *client, *tmp; int fd, ret; - ret = task_get_notification(t); + ret = task_get_notification(ct->task); if (ret < 0) return ret; ret = execute_server_command(&s->rfds); @@ -972,10 +975,12 @@ static void register_command_task(uint32_t cookie, struct sched *s) ct->fd = setup_command_socket_or_die(); ct->cookie = cookie; - ct->task.pre_select = command_pre_select; - ct->task.post_select = command_post_select; - sprintf(ct->task.status, "afs command task"); - register_task(s, &ct->task); + ct->task = task_register(&(struct task_info) { + .name = "afs command", + .pre_select = command_pre_select, + .post_select = command_post_select, + .context = ct, + }, s); } /** @@ -1007,6 +1012,7 @@ __noreturn void afs_init(uint32_t cookie, int socket_fd) s.default_timeout.tv_sec = 0; s.default_timeout.tv_usec = 999 * 1000; ret = schedule(&s); + sched_shutdown(&s); out_close: close_afs_tables(); out: