Skip to content

Commit

Permalink
mxqd: Fix "Main Loop freed N slots" message
Browse files Browse the repository at this point in the history
Count released slots in fspool_scan so that the "Main Loop freed N
slots" message correctly shows the number of freed slots and not the
number of finished jobs.

Also shorten the message

    slots_returned=N :: Main Loop freed N slots.

to just

    Main loop freed N slots.

which pairs with the message

    Main loop started N slots.
  • Loading branch information
donald committed Aug 23, 2021
1 parent 4a0b7c9 commit f8c7531
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions mxqd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2022,6 +2022,7 @@ static int fspool_process_file(struct mxq_server *server,char *filename, uint64_
struct mxq_job_list *jlist;
struct mxq_job *job;
struct mxq_group *group;
int slots_returned = 0;

in=fopen(filename,"r");
if (!in) {
Expand Down Expand Up @@ -2088,12 +2089,12 @@ static int fspool_process_file(struct mxq_server *server,char *filename, uint64_
job->stats_status = status;
job->stats_rusage = rusage;

job_has_finished(server, group, jlist);
slots_returned = job_has_finished(server, group, jlist);
unlink(filename);
res = server_update_daemon_statistics(server);
if (res < 0)
mx_log_err("recover: failed to update daemon instance statistics: %m");
return(0);
return(slots_returned);
}

static int fspool_is_valid_name_parse(const char *name, unsigned long long int *job_id) {
Expand Down Expand Up @@ -2127,6 +2128,7 @@ static int fspool_scan(struct mxq_server *server) {
int res;
unsigned long long int job_id;
char *filename;
int slots_returned = 0;


entries=scandir(server->finished_jobsdir,&namelist,&fspool_is_valid_name,&alphasort);
Expand All @@ -2139,15 +2141,15 @@ static int fspool_scan(struct mxq_server *server) {
mx_asprintf_forever(&filename,"%s/%s",server->finished_jobsdir,namelist[i]->d_name);
fspool_is_valid_name_parse(namelist[i]->d_name,&job_id);
res=fspool_process_file(server,filename,job_id);
if (res==0) {
cnt++;
if (res>0) {
slots_returned += res;
}
free(namelist[i]);
free(filename);
}

free(namelist);
return cnt;
return slots_returned;
}

static int file_exists(char *name) {
Expand Down Expand Up @@ -2697,7 +2699,7 @@ int main(int argc, char *argv[])
slots_returned += fspool_scan(server);

if (slots_returned)
mx_log_info("slots_returned=%lu :: Main Loop freed %lu slots.", slots_returned, slots_returned);
mx_log_info("Main loop freed %lu slots.", slots_returned);

group_cnt = load_running_groups(server);
if (group_cnt)
Expand Down

0 comments on commit f8c7531

Please sign in to comment.