# HG changeset patch # User LordOfWar # Date 2009-10-14 14:20:48 # Node ID f3f23306d2b91762d67e164b986ad2bc42917d57 # Parent a262fec921d25ab451cbc9b9c1e0e878ca21ac9a attempting to fix distrenjob_enqueue() diff --git a/src/server/distrend.c b/src/server/distrend.c --- a/src/server/distrend.c +++ b/src/server/distrend.c @@ -308,14 +308,15 @@ int prepare_distrenjob(struct distrenjob /** distrenjob_enqueue: This function adds the job to the queue based on its priority */ -void distrenjob_enqueue(struct distrenjob *head, struct distrenjob *job) { +void distrenjob_enqueue(struct distrenjob *head, struct distrenjob *job) +{ struct distrenjob *prev_job = head; // create pointer to previous job struct distrenjob *current_job; // create pointer to current_job (which job is being compared to) // iterate through linked list of jobs - for(current_job = head; current_job != NULL; current_job = current_job->next){ + for(current_job = head->next; 1; current_job = current_job->next){ if(current_job == NULL){ // if it has reached the end of the list, add job there - current_job = job; + prev_job->next = job; break; } else if(job->priority < current_job->priority){ // if job's priority is less than current_job's priority, insert job