Changeset - 82e46a3537bb
[Not reviewed]
default
0 1 0
Nathan Brink (binki) - 16 years ago 2009-07-15 13:28:47
ohnobinki@ohnopublishing.net
added blendjob_get(), moved func prototypes
1 file changed with 31 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/server/distrend.c
Show inline comments
 
@@ -28,35 +28,32 @@
 

	
 

	
 
#include "execio.h"
 
#include "options.h"
 
#include <confuse.h>
 
#include <stdio.h>
 
#include <stdlib.h>
 
#include <malloc.h>
 
#include <unistd.h> /* getopt */
 
#include <time.h>
 

	
 

	
 
/*
 
  internally defined funcs's prototypes
 
*/
 
void status_report_generator();
 
void blendjob_remove(struct blendjob **head, struct blendjob *bj);
 

	
 
// Global Vars, try to cut down on these
 
int jobnum = 0; // The next job number to create in the queue
 
jobnum_t jobnum = 0; // The next job number to create in the queue
 
int hcfjob; // Highest consecutively finished job
 
int highest_jobnum; // The job number of the most recently created job, this is used when creating new jobs
 

	
 
typedef unsigned int jobnum_t;
 

	
 
/* ******************* Structs ************************ */
 

	
 
// Stores config info? editmycomment
 
struct distrend_config
 
{
 
  cfg_t *mycfg;
 
  struct options_common *options;
 
  struct distrend_listen **listens; /*< Null terminated array of structs */
 
};
 

	
 

	
 

	
 
@@ -77,49 +74,55 @@ struct general_info {
 
	unsigned short int free_clients;
 
	unsigned short int rendering_clients;//
 
	unsigned short int total_finished_jobs; //
 
	unsigned int total_frames_rendered; //
 
} general_info;
 

	
 
// Stores Blender Job Info
 
struct blendjob {
 
  struct blendjob *next; /* next will be NULL unless if there is another blendjob */
 
  char *name;
 
  char *submitter;
 
  char *email;
 
  unsigned int jobnum;
 
  jobnum_t jobnum;
 
  int priority;  // 1 is lowest, 10 is highest, 0 means the job is done
 
  int percent_done;
 
  int completed_frames; // number of completed frames for stats/etc
 
  int assigned_frames; // number of assigned frames (that are not yet completed) for stats/etc
 
  int total_frames; // how many frames are in the animation for stats/etc (unassigned frames)
 
  int avg_render_time; // average seconds it took to render a frame
 
  unsigned int time_remaining; // estimated seconds remaining till render is complete (up to 49, 710 days)
 
							   // we can have the client computer convert it into days, hours, etc if they wish to view it
 
  struct frameset *frameset;
 
};
 

	
 

	
 
// Frameset Structure
 
struct frameset {
 
	int frame_num; // frame number to render
 
	char slave_name; // user that frame is assigned to
 
	int frame_status; // status of frame, 0= unassigned, 1= taken, 2= done
 
	clock_t start_time; // time the frame was started
 
	int time_to_render; // the total seconds it took to render the frame
 
} frameset[]; // Frameset array is generated by status_report_generator function
 
                         // Using this method to save memory, because if animation starts on a high frame number, it would waste a lot of RAM on empty structures
 

	
 

	
 
/*
 
  internally defined funcs's prototypes
 
*/
 
void status_report_generator();
 
void blendjob_remove(struct blendjob **head, struct blendjob *bj);
 

	
 
struct blendjob *blendjob_get(struct blendjob *head, jobnum_t jobnum);
 

	
 
/* ********************** Functions ************************* */
 

	
 
void start_data(){
 

	
 
	if(1 == 0){
 
		// retrieve total_finished_jobs and total_finished_frames from xml file
 
	}
 
	else{
 
		general_info.total_finished_jobs = 0;
 
		general_info.total_frames_rendered = 0;
 
	}
 
@@ -330,24 +333,45 @@ void blend_frame_watchdog(struct blendjo
 
      {
 
	if((blendjob_ptr->frameset[counter].start_time + (watchdog_forgiveness * 3600)) < clock()) 
 
	  /*
 
	    If frame is not completed within the number of hours specified by watchdog_forgiveness 
 
	    Then change the frame status to unassigned
 
	  */
 
	  blendjob_ptr->frameset[counter].frame_status = 0;
 
      }
 

	
 
}
 

	
 
/**
 
   Finds a blendjob struct based on the jobnum
 
   @arg jobnum job number to search for
 
   @return NULL on job doesn't exist
 
 */
 
struct blendjob *blendjob_get(struct blendjob *head, jobnum_t jobnum)
 
{
 
  struct blendjob *blendjob_ptr;
 
  
 
  /*
 
    The conditions of the for loop will leave blendjob_ptr at NULL if the end of the list is reached. It will leave it pointing to the correct job if it is found.
 
   */
 
  for(blendjob_ptr = head;
 
      blendjob_ptr
 
	&& blendjob_ptr->jobnum != jobnum;
 
      blendjob_ptr = blendjob_ptr->next);
 
  
 
  return blendjob_ptr;
 
}
 

	
 

	
 
/**
 
   Removes a blendjob from the blendjob linkelist.
 

	
 
   @arg head a double pointer. the head pointer will have to be changed if blendjob == *head. Thus, make sure that the pointer points to the pointer to the head that all functions use. (I'm going to come back to this and misunderstand myself ;-))
 
 */
 
void blendjob_remove(struct blendjob **head, struct blendjob *bj)
 
{
 
  struct blendjob *previous_blendjob;
 
  
 
  if(bj == *head)
 
    *head = bj->next;
 
  else
 
    {
0 comments (0 inline, 0 general)