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
 
@@ -313,27 +313,55 @@ void add_job_to_queue(struct distrenjob 
 

	
 
  // iterate through linked list of jobs
 
  for(current_job = head; current_job != NULL; current_job = current_job->next){
 
    if(current_job == NULL){ // if it has reached the end of the list, add job there
 
      current_job = 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 lowest priority
 
      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;
 
}
 

	
 

	
 

	
 
/**
 
  Frame Finder: matches your computer up with a lovely frame to render
 
  TODO: Major issue here, the client needs to know the frame number, AND the job number!
 
  Notice that this function starts by looking at the oldest job first
 

	
 
	TODO: Link this up with the main() function to check if there are frames available or not and provide jobnum/framenum to the client
 

	
 
  @return 0 success, other: error
 
*/
 
int frame_finder(struct distrenjob *head, struct distrenjob **job, struct frameset **frame)
0 comments (0 inline, 0 general)