Skip to content

Commit

Permalink
Keep all_jobs_used consistent
Browse files Browse the repository at this point in the history
Only decrement all_jobs_used when we actually remove a job from the hash

If a job does not have an id then it is not in the hash so do not attempt
to remove it. Such temp jobs are used in prot.c to return stats
  • Loading branch information
gbarr committed Nov 27, 2008
1 parent d7b80cd commit b9df373
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions job.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,25 +158,26 @@ job_hash_free(job j)
if (jh == j) {
/* Special case the first */
all_jobs[index] = jh->ht_next;
all_jobs_used--;
} else {
job tmp;
while (jh->ht_next && jh->ht_next != j) jh = jh->ht_next;
if (jh->ht_next) {
all_jobs_used--;
tmp = jh->ht_next;
jh->ht_next = jh->ht_next->ht_next;
}
}
}

all_jobs_used--;
}

void
job_free(job j)
{
if (j) {
TUBE_ASSIGN(j->tube, NULL);
job_hash_free(j);
if (j->id) job_hash_free(j);
}

free(j);
Expand Down

0 comments on commit b9df373

Please sign in to comment.