From 5254df7e470dc49a29f91fa8185b98c40246f5ea Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sat, 1 Mar 2014 12:55:38 +0100 Subject: [PATCH] sched: Remove ->owned_by_sched. With register_task() gone, the ->owned_by_sched field of struct sched is always true (it gets set in task_register()). So we can remove it. --- sched.c | 12 ++---------- sched.h | 2 -- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/sched.c b/sched.c index fe57e03e..1b83b704 100644 --- a/sched.c +++ b/sched.c @@ -45,8 +45,7 @@ static void unlink_and_free_task(struct task *t) { PARA_INFO_LOG("freeing task %s\n", t->status); list_del(&t->node); - if (t->owned_by_sched) - free(t); + free(t); } //#define SCHED_DEBUG 1 @@ -82,10 +81,7 @@ static unsigned sched_post_select(struct sched *s) } call_post_select(s, t); t->notification = 0; - if (t->error < 0) { - if (!t->owned_by_sched) - list_del(&t->node); - } else + if (t->error >= 0) num_running_tasks++; } return num_running_tasks; @@ -169,8 +165,6 @@ int task_reap(struct task **tptr) t = *tptr; if (!t) return 0; - if (!t->owned_by_sched) - return 0; if (t->error >= 0) return 0; if (t->dead) /* will be freed in sched_post_select() */ @@ -234,7 +228,6 @@ struct task *task_register(struct task_info *info, struct sched *s) t->pre_select = info->pre_select; t->post_select = info->post_select; t->context = info->context; - t->owned_by_sched = true; list_add_tail(&t->node, &s->task_list); return t; } @@ -249,7 +242,6 @@ struct task *task_register(struct task_info *info, struct sched *s) */ void *task_context(struct task *t) { - assert(t->owned_by_sched); return t->context; } diff --git a/sched.h b/sched.h index 0b7df7e8..db6ee7dc 100644 --- a/sched.h +++ b/sched.h @@ -53,8 +53,6 @@ struct task { char status[255]; /** If less than zero, the task was notified by another task. */ int notification; - /** Whether the task structure should be freed in sched_shutdown(). */ - bool owned_by_sched; /** True if task is in error state and exit status has been queried. */ bool dead; /** Usually a pointer to the struct containing this task. */ -- 2.39.2