Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
mxqd_config: Add server_sort_groups_by_priority
Add a utility routing to sort the groups of all users of the server to
their group priority.
  • Loading branch information
donald committed Jul 4, 2017
1 parent c956da7 commit e10e3d0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions mxqd_control.c
Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion mxqd_control.h
Expand Up @@ -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

0 comments on commit e10e3d0

Please sign in to comment.