Changeset - f3f23306d2b9
[Not reviewed]
default
0 1 0
LordOfWar - 16 years ago 2009-10-14 14:20:48

attempting to fix distrenjob_enqueue()
1 file changed with 4 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/server/distrend.c
Show inline comments
 
@@ -305,20 +305,21 @@ int prepare_distrenjob(struct distrenjob
 

	
 
  return 0;
 
}
 

	
 

	
 
/** 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
 
      prev_job->next = job;                        // keep in mind 1 is the highest priority given to jobs, head has a
 
      job->next = current_job;                     // priority of zero so it will always be before other jobs
 
      break;
0 comments (0 inline, 0 general)