Changeset - bbc92828afdd
[Not reviewed]
default
0 1 0
LordOfWar - 16 years ago 2009-09-12 18:45:51

created function \"change_job_priority\" and \"remove_job\" (this remove_job function recieves a job number and returns structure distrenjob, it was made to assist the change_job_priority function)

I also fixed an error where add_job_to_queue wasn't updating its prev_job pointer, which would of resulted in the loss of jobs between head and where the new job is inserted.
1 file changed with 28 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/server/distrend.c
Show inline comments
 
@@ -322,9 +322,37 @@ void add_job_to_queue(struct distrenjob 
 
      job->next = current_job;
 
      break;
 
    }
 

	
 
    prev_job = current_job;
 
  } // end of for statement
 
}
 

	
 
void change_job_priority(int jobnum, int new_priority){
 
  struct distrenjob *job = &remove_job(jobnum);
 
  job->priority = new_priority;
 
  add_job_to_queue(job);
 
}
 

	
 
distrenjob remove_job(int jobnum_t){
 
  struct distrenjob *job;
 
  struct distrenjob *prev_job = head;
 

	
 
  for(job = head; job != NULL; job = job->next){
 
    if(job == NULL){
 
      return NULL;
 
    }
 
    if(job->jobnum = jobnum_t){
 
      prev_job = job->next;
 
      return job;
 
    }
 

	
 
    prev_job = job;
 
  }
 

	
 
  // job was not found if this point is reached
 
  return NULL;
 
}
 

	
 

	
 

	
 
/**
0 comments (0 inline, 0 general)