Changeset - e0d0a8f4daed
[Not reviewed]
default
0 1 0
Ethan Zonca (ethanzonca) - 16 years ago 2010-02-13 18:08:47
e@ethanzonca.com
Commenting for queries
1 file changed with 19 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/server/distrend.c
Show inline comments
 
@@ -224,12 +224,13 @@ int main(int argc, char *argv[])
 
  return 0;
 
}
 

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

	
 
/** Dumps all data in RAM to an xml file (such as current jobs, etc) which is parsed by start_data. Remember to invoke this before shutting down! @TODO: Fill this stub*/
 
// @QUERY: Obselete function, get rid of me!
 
int xml_dump()
 
{
 
  return 0;
 
}
 
/**
 
   Performs command stored in a client's request. @TODO: Fill stub
 
@@ -239,12 +240,13 @@ int distrend_do()
 
  return 0;
 
}
 

	
 
/** 
 
    Fill variables at startup from XML dumps or defaults
 
 */
 
// @QUERY: Obselete function, as data is stored in sql now.
 
int start_data(struct general_info *general_info)
 
{
 
  struct stat buffer;
 

	
 
  /**
 
     defaults
 
@@ -281,15 +283,15 @@ int start_data(struct general_info *gene
 
    }
 
  
 
  return 0;
 
}
 

	
 
/** Finish-Setter: Sets a frame to the "completed" status.*/
 
// @QUERY: update `distren`.`Job` set `Finish_Confirmed`=1 where `Job_Key`='1';
 
void finish_frame(struct general_info *geninfo, struct distrenjob *distrenjob, int frame)
 
{
 
  // @QUERY: update `distren`.`Job` set `Finish_Confirmed`=1 where `Job_Key`='1';
 
  distrenjob->frameset[frame].status = FRAMESETSTATUS_DONE;
 
  distrenjob->total_render_time = distrenjob->total_render_time + (clock() - distrenjob->frameset[frame].start_time);
 
  distrenjob->completed_frames ++;
 
  distrenjob->assigned_frames --;
 
  geninfo->total_frames_rendered ++; /*< Increase total frames var for stats */
 

	
 
@@ -298,12 +300,13 @@ void finish_frame(struct general_info *g
 
}
 

	
 
/**
 
   checks to see if a job is actually done.
 
   - scans the folder of the job to make sure all output files are present
 
*/
 
// @QUERY: Needs some complex query work
 
int mortition(struct general_info *geninfo, struct distrenjob *job)
 
{
 
  short int isJobDone;
 
  int counter;
 
  char *path_and_number;
 
  struct stat buffer;
 
@@ -351,12 +354,13 @@ int mortition(struct general_info *genin
 

	
 
/**
 
   scans the frames of a job to initialize a job after server
 
   @return 0 if the job is completely done and there are no missing frames,
 
           1 if missing frames are found.
 
*/
 
// @QUERY: Obselete with mysql job/frame storage
 
int restoreJobState(struct distrenjob *job)
 
{
 
  short int isJobDone;
 
  int counter;
 
  char *path_and_number;
 
  struct stat buffer;
 
@@ -381,12 +385,13 @@ int restoreJobState(struct distrenjob *j
 
/**
 
   creates a structure from starting data, then calls another
 
   function to actually add that struct to the queue.
 

	
 
   Passed strings must be free()d by the caller.
 
*/
 
// @QUERY: Likely obselete, as jobs are submitted via the web
 
int prepare_distrenjob(struct general_info *geninfo, int type, char *name, char *submitter, int priority, int start_frame, int end_frame, int width, int height)
 
{
 
  int counter;
 
  int counter2;
 
  int tmp;
 
  char *serialfile;
 
@@ -451,12 +456,13 @@ int prepare_distrenjob(struct general_in
 

	
 

	
 
/**
 
   Adds the job to the queue based on its priority.
 
   Updates geninfo->jobs_in_queue.
 
*/
 
// @QUERY: Likely obselete, enqueueing is done via web interface
 
int distrenjob_enqueue(struct general_info *geninfo, struct distrenjob *job)
 
{
 
  struct distrenjob *prev_job;
 
  struct distrenjob *current_job;
 
  struct distrenjob *head;
 

	
 
@@ -495,14 +501,14 @@ int distrenjob_enqueue(struct general_in
 

	
 
  geninfo->jobs_in_queue ++;
 
  return 0;
 
}
 

	
 
/** Changes the priority of an existing (and maybe running) job. @arg head I may end up changing the head if job == head */
 
// @QUERY: update `distren`.`Job` set `Priority`='12', `Finish_Confirmed`=1 where `Job_Key`='1';
 
int change_job_priority(struct general_info *geninfo, struct distrenjob *job, int new_priority){
 
  // @QUERY: update `distren`.`Job` set `Priority`='12', `Finish_Confirmed`=1 where `Job_Key`='1';
 
  struct distrenjob *current_job;
 
  struct distrenjob *prev_job;
 
  char *serialname;
 

	
 
  distrenjob_remove(geninfo, job);
 
  job->priority = new_priority;
 
@@ -543,15 +549,15 @@ int change_job_priority(struct general_i
 
/**
 
  Frame Finder: matches your computer up with a lovely frame to render, starts looking at oldest job first
 
  @TODO: We must return both jobnum and framenum
 
  @TODO: Add calls in main()
 
  @return 0 success, other: error
 
*/
 
// @QUERY: Frame_Get()
 
int find_jobframe(struct general_info *geninfo, struct distrenjob **job, struct frameset **frame)
 
{
 
  // @QUERY: distren.Frame_Get()
 
  if(geninfo->hibernate)
 
    return 1;
 

	
 
  unsigned int frame_counter;
 
  unsigned short int found;
 

	
 
@@ -591,12 +597,13 @@ int find_jobframe(struct general_info *g
 
  *job = distrenjob_ptr;
 
  *frame = &distrenjob_ptr->frameset[frame_counter];
 

	
 
  return 0;
 
}
 

	
 
// @QUERY: Obselete?
 
int find_jobframe_from_job(struct distrenjob *distrenjob_ptr, struct distrenjob **job, struct frameset **frame)
 
{
 
  unsigned int frame_counter;
 
  unsigned short int found;
 

	
 
  found = 0;
 
@@ -628,12 +635,13 @@ int find_jobframe_from_job(struct distre
 
  *frame = &distrenjob_ptr->frameset[frame_counter];
 

	
 
  return 0;
 
}
 

	
 
// find a frame to render when the job that the last frame was for no longer exists
 
// @QUERY: Obselete?
 
int find_jobframe_new(struct general_info *geninfo, int rend_pwr, struct distrenjob **job, struct frameset **frame)
 
{
 
  if(geninfo->hibernate)
 
    return 1;
 

	
 
  float power_difference;
 
@@ -679,12 +687,13 @@ int find_jobframe_new(struct general_inf
 
  job_to_render->assigned_render_power = job_to_render->assigned_render_power + rend_pwr;
 

	
 
  return 0;
 
}
 

	
 
// gets a frame to render from the same job that the previously rendered frame was from
 
// @QUERY: Obselete?
 
int find_jobframe_again(struct general_info *geninfo, int jobnum, int rend_pwr, struct distrenjob **job, struct frameset **frame)
 
{
 
  if(geninfo->hibernate)
 
    return 1;
 

	
 
  short int found;
 
@@ -743,12 +752,13 @@ void frame_watchdog(struct distrenjob *d
 

	
 
/**
 
   Finds a distrenjob struct based on the jobnum
 
   @arg jobnum job number to search for
 
   @return NULL on job doesn't exist
 
 */
 
// @QUERY: Obselete
 
struct distrenjob *distrenjob_get(struct distrenjob *head, jobnum_t jobnum)
 
{
 
  struct distrenjob *distrenjob_ptr;
 

	
 
  /*
 
    The conditions of the for loop will leave distrenjob_ptr at NULL if the end of the list is reached. It will leave it pointing to the correct job if it is found.
 
@@ -766,12 +776,13 @@ struct distrenjob *distrenjob_get(struct
 
   Removes a distrenjob from the distrenjob linked list. It does not free the
 
   distrenjob, however. You should do that with distrenjob_free() from distrenjob.h.
 
   Updates geninfo->jobs_in_queue.
 

	
 
   @arg head pointer to the head of the linkedlist of distrenjobs
 
 */
 
// @QUERY: Obselete: removal done via web interface
 
void distrenjob_remove(struct general_info *geninfo, struct distrenjob *bj)
 
{
 
  struct distrenjob *previous_distrenjob;
 

	
 
  for(previous_distrenjob = &geninfo->head;
 
      previous_distrenjob
 
@@ -916,12 +927,13 @@ int import_general_info(struct general_i
 
}
 

	
 
/**
 
   determines path to the distenjob XML file and
 
   calls distrenjob_unserialize()
 
 */
 
// @QUERY: Likely obselete (don't remove at request of ohnobinki)
 
int restore_distrenjob(struct general_info *geninfo, struct distrenjob **distrenjob, jobnum_t jobnum)
 
{
 
  int tmp;
 
  char *file_name;
 

	
 
  tmp = job_getserialfilename(&file_name, geninfo, jobnum, 0);
 
@@ -934,12 +946,13 @@ int restore_distrenjob(struct general_in
 
            jobnum, file_name);
 
  
 
  free(file_name);
 
  return tmp;
 
}
 

	
 
// @QUERY: Likely obselete (don't remove at request of ohnobinki)
 
int updateJobStatsXML(struct distrenjob *job)
 
{
 
          xmlTextWriterPtr writer;
 
          char *tmp;
 

	
 
          _distren_asprintf(&tmp, "stor/job%d/stats.xml", job->jobnum);
 
@@ -982,12 +995,13 @@ int updateJobStatsXML(struct distrenjob 
 

	
 

	
 
/**
 
   updates job_list.xml which lists all the jobs in the queue
 
   @return 0 means success
 
*/
 
// @QUERY: Likely obselete (don't remove at request of ohnobinki)
 
int update_xml_joblist(struct general_info *geninfo)
 
{
 
  struct distrenjob *job;
 
  xmlTextWriterPtr writer;
 
  char *tmp;
 
  int counter;
 
@@ -1049,12 +1063,13 @@ int update_xml_joblist(struct general_in
 

	
 
/**
 
 returns 0 if completed successfully
 
 this reads a list of jobs in the queue before DistRen was shut down
 
 and then adds the jobs to the queue, as if it were never shut down
 
*/
 
// @QUERY: Likely obselete (don't remove at request of ohnobinki)
 
int createQueueFromXML(struct general_info *geninfo)
 
{
 
  int tmp;
 

	
 
  xmlDocPtr doc;
 
  xmlNodePtr cur;
 
@@ -1108,12 +1123,13 @@ int createQueueFromXML(struct general_in
 

	
 
/**
 
   inserts jobs at front of queue, starting
 
   with the last job in the job_list xml file
 
   to preserve the order of the queue
 
*/
 
// @QUERY: Likely obselete (don't remove at request of ohnobinki)
 
int reCreateQueueFromXML(struct general_info *geninfo, xmlDocPtr doc, xmlNodePtr current)
 
{
 
  struct distrenjob *holder; // holds the job that "was" after head, so that the new struct can be inserted after head
 
  struct distrenjob *job; // job to be added
 
  xmlChar *tmp;
 
  jobnum_t job_num;
0 comments (0 inline, 0 general)