Changeset - 73e1c0d6e315
[Not reviewed]
default
0 1 0
LordOfWar - 16 years ago 2009-09-16 22:45:54

-fixed a minor error in finish_frame() where the amount of assigned frames was increased 1 instead of decreased 1.
-mortition() now decreases general_info.jobs_in_queue by one if the job is done and it calls distrenjob_remove() to remove the job from the linked list database.
-frame_finder() now increases the amount of assigned_frames by 1 if a frame to render is found
-distrenjob_remove() now decreases the amount of general_info.jobs_in_queue by 1
-prepare_distrenjob() now initializes assigned_frames and completed_frames at 0
1 file changed with 9 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/server/distrend.c
Show inline comments
 
@@ -152,15 +152,17 @@ int start_data(){
 
}
 

	
 
/** Finish-Setter: Sets a frame to the "completed" status.*/
 
void finish_frame(struct distrenjob *head, struct distrenjob *distrenjob, int frame){
 
  distrenjob->frameset[frame].status = 2;
 
  distrenjob->frameset[frame].time_to_render = (clock() - distrenjob[jobnum].frameset[frame].start_time); // Consider changing time-to-render to time-for-frame or something?
 
  /* TODO: calculating the average render time like this may have a small amount of error, because the number is truncated to an integer of seconds every time... does it matter? */
 
  /* we could keep track of the total render time... would make calculation a lot easier and more accurate */
 
  distrenjob->avg_render_time = ((distrenjob->avg_render_time*(distrenjob->completed_frames)) + distrenjob->frameset[frame].time_to_render)/(distrenjob->completed_frames + 1);
 
  distrenjob->completed_frames++;
 
  distrenjob->assigned_frames++;
 
  distrenjob->assigned_frames--;
 
  general_info.total_frames_rendered++; // Increase total frames var for stats
 

	
 
  if(distrenjob->completed_frames == distrenjob->total_frames)
 
    {
 
      mortition(head, distrenjob);
 
    }
 
@@ -186,12 +188,13 @@ void mortition(struct distrenjob *head, 
 
        }
 
    }
 

	
 
  if(isJobDone)
 
    {
 
      distrenjob_remove(&head, job);
 
      general_info.jobs_in_queue--;
 
    }
 
}
 

	
 
/**
 
   creates a structure from starting data, then calls another function to actually add that struct to the queue
 
*/
 
@@ -207,12 +210,15 @@ void prepare_distrenjob(struct frameset 
 
  distrenjob->submitter = submitter;
 
  distrenjob->email = email;
 
  distrenjob->priority = priority;
 
  distrenjob->total_frames = (end_frame - start_frame + 1); // sets the total number of frames in animation for status purposes
 
  distrenjob->frameset = malloc(distrenjob->total_frames);
 

	
 
  distrenjob->assigned_frames = 0;
 
  distrenjob->completed_frames = 0;
 

	
 
  /* @TODO: should the aove be malloc(sizeof(struct frameset) * distrenjob->total_frames? */
 
  /*
 
  distrenjob->frameset = malloc(sizeof(struct frameset) * numframes);
 
  if(!job->frameset)
 
    fprintf(stderr, "Error allocating memory\n");
 
  */
 
@@ -311,12 +317,13 @@ int frame_finder(struct distrenjob *head
 
          if(distrenjob_ptr->frameset[your_frame].status == 0)
 
            {
 
              found = 1;
 
              your_job_type = distrenjob_ptr->type;
 
              distrenjob_ptr->frameset[your_frame].status = 1;
 
              distrenjob_ptr->frameset[your_frame].start_time = clock();
 
              distrenjob_ptr->assigned_frames++;
 
              break;
 
            }
 
    }
 

	
 
// end of while statement... job must be found or linked list must be ended to get out of here
 
      if(!found)
 
@@ -405,12 +412,13 @@ 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;
 
    }
 
  general_info.jobs_in_queue--;
 
}
 

	
 

	
 
/* Grabs config info from confs */
 
int distrend_do_config(int argc, char *argv[], struct distrend_config **config)
 
{
0 comments (0 inline, 0 general)