Changeset - 5bee5e566377
[Not reviewed]
default
0 2 0
Nathan Brink (binki) - 16 years ago 2009-09-13 14:45:41
ohnobinki@ohnopublishing.net
removed remove_job, use distrenjob_remove
2 files changed with 12 insertions and 39 deletions:
0 comments (0 inline, 0 general)
src/server/distrend.c
Show inline comments
 
@@ -69,13 +69,12 @@ struct general_info {
 

	
 
/*
 
  internally defined funcs's prototypes
 
*/
 
void status_report_generator(struct distrenjob **distrenjobs_head);
 
void distrenjob_remove(struct distrenjob **head, struct distrenjob *bj);
 
struct distrenjob *remove_job(int jobnum_t);
 

	
 
struct distrenjob *distrenjob_get(struct distrenjob *head, jobnum_t jobnum);
 
struct distrenjob *head; /*@TODO:declare struct with no starting data */
 

	
 
/* Global Vars, try to cut down on these */
 
jobnum_t jobnum = 0; // The next job number to create in the queue
 
@@ -287,12 +286,13 @@ void status_report_generator(struct dist
 

	
 
	  if(finished_frames == distrenjob_ptr->total_frames)
 
	    /* If all frames are complete */
 
	    {
 
	      distrenjob_ptr->priority = 0; /*< set priority to zero to indicate job is complete */
 
	      distrenjob_remove(distrenjobs_head, distrenjob_ptr); /*< remove this job from the linkedlist */
 
	      distrenjob_free(distrenjob_ptr);
 
	      general_info.total_finished_jobs++; /*< add one to the total finished jobs */
 

	
 
	    }
 
	  else if (finished_frames > distrenjob_ptr->total_frames)
 
	    /* just in case ;-) */
 
	    {
 
@@ -311,13 +311,15 @@ void status_report_generator(struct dist
 
    } /* while(distrenjob_ptr) */
 

	
 
  general_info.jobs_in_queue = (highest_jobnum - general_info.total_finished_jobs); /*< extraneous parentheses! */
 
}
 

	
 

	
 
/** Structure Builder: This function creates frame array based on the total number of frames to be rendered, which will then be parsed by function frame_farmer. */
 
/**
 
   Structure Builder: This function creates frame array based on the total number of frames to be rendered, which will then be parsed by function frame_farmer. 
 
*/
 
void add_job_to_queue(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){
 
@@ -329,48 +331,24 @@ void add_job_to_queue(struct distrenjob 
 
      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;
 
  job = remove_job(jobnum);
 
  job->priority = new_priority;
 
  add_job_to_queue(job);
 
  } /* for(current_job) */
 
}
 

	
 
/**
 
   Removes job from queue without freeing/deleting it. Meant to be temporary.
 
   @arg head I may end up changing the head if job == head
 
 */
 
struct 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;
 
void change_job_priority(struct distrenjob **head, struct distrenjob *job, int new_priority){
 
  distrenjob_remove(head, job);
 
  job->priority = new_priority;
 
  add_job_to_queue(job);
 
}
 

	
 

	
 

	
 
/**
 
  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
 
@@ -510,18 +488,12 @@ void distrenjob_remove(struct distrenjob
 

	
 
      /*
 
	This removes references to bj from the linked list. I.E., we now skip bj when iterating through the list
 
       */
 
      previous_distrenjob->next = bj->next;
 
    }
 

	
 
  /*
 
     @lordofwar: the magic deallocation of memory ;-)
 
   */
 
  free(bj->frameset);
 
  free(bj);
 
}
 

	
 

	
 
/* Grabs config info from confs */
 
int distrend_do_config(int argc, char *argv[], struct distrend_config **config)
 
{
src/server/distrenjob.c
Show inline comments
 
@@ -13,13 +13,12 @@
 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
  GNU Affero General Public License for more details.
 

	
 
  You should have received a copy of the GNU Affero General Public License
 
  along with DistRen.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#include "distrenjob.h"
 
#include "slavefuncs.h"
 
#include "asprintf.h"
 

	
 
#include <libxml/tree.h>
 
#include <libxml/parser.h>
 
@@ -30,12 +29,14 @@ void distrenjob_free(struct distrenjob *
 

	
 
  dj = *distrenjob;
 
  xmlFree(dj->name);
 
  xmlFree(dj->submitter);
 
  xmlFree(dj->email);
 

	
 
  free(dj->frameset);
 

	
 
  free(dj);
 
  *distrenjob = NULL;
 
}
 

	
 
int distrenjob_new(struct distrenjob **distrenjob)
 
{
0 comments (0 inline, 0 general)