diff --git a/mxqd_control.c b/mxqd_control.c index 7a68d564..36814e26 100644 --- a/mxqd_control.c +++ b/mxqd_control.c @@ -537,3 +537,24 @@ void server_sort_users_by_running_global_slot_count(struct mxq_server *server) assert(server); mx_sort_linked_list(&server->users,cmp_users_by_global_running_slots,get_users_nextptr); } + +static int cmp_groups_by_priority(struct mxq_group_list *g1,struct mxq_group_list *g2) +{ + return + g1->group.group_priority > g2->group.group_priority ? 1 + : g1->group.group_priority < g2->group.group_priority ? -1 + : 0; +} + +static struct mxq_group_list **get_groups_nextptr(struct mxq_group_list *g) { + return &g->next; +} + +void server_sort_groups_by_priority(struct mxq_server *server) { + assert(server); + struct mxq_user_list *user; + + for (user=server->users;user;user=user->next) { + mx_sort_linked_list(&user->groups,cmp_groups_by_priority,get_groups_nextptr); + } +} diff --git a/mxqd_control.h b/mxqd_control.h index 3ea69a5a..a0032ccd 100644 --- a/mxqd_control.h +++ b/mxqd_control.h @@ -20,7 +20,7 @@ struct mxq_job_list *group_list_add_job(struct mxq_group_list *glist, struct mxq int server_remove_orphaned_groups(struct mxq_server *server); void job_list_remove_self(struct mxq_job_list *jlist); - +void server_sort_groups_by_priority(struct mxq_server *server); #endif