}
static int server_socket;
+static struct command_task command_task_struct;
+static struct signal_task signal_task_struct;
-void loop(void)
+static void unregister_tasks(void)
{
- for (;;)
- sleep(1);
+ unregister_task(&command_task_struct.task);
+ unregister_task(&signal_task_struct.task);
}
static void afs_shutdown(enum osl_close_flags flags)
t->ret = 1;
if (st->signum == SIGUSR1)
return; /* ignore SIGUSR1 */
- afs_shutdown(OSL_MARK_CLEAN);
t->ret = -E_SIGNAL_CAUGHT;
+ unregister_tasks();
}
static void register_signal_task(void)
{
- static struct signal_task signal_task_struct;
struct signal_task *st = &signal_task_struct;
st->fd = para_signal_init();
PARA_INFO_LOG("signal pipe: fd %d\n", st->fd);
static void register_command_task(uint32_t cookie)
{
- static struct command_task command_task_struct;
struct command_task *ct = &command_task_struct;
ct->fd = setup_command_socket_or_die();
ct->cookie = cookie;
s.default_timeout.tv_sec = 0;
s.default_timeout.tv_usec = 99 * 1000;
ret = sched(&s);
- assert(ret < 0);
- PARA_EMERG_LOG("%s\n", PARA_STRERROR(-ret));
+ if (ret < 0)
+ PARA_EMERG_LOG("%s\n", PARA_STRERROR(-ret));
+ afs_shutdown(OSL_MARK_CLEAN);
exit(EXIT_FAILURE);
}