# HG changeset patch # User LordOfWar # Date 2009-09-16 22:45:54 # Node ID 73e1c0d6e315f579843156c0609dd5563368a5f1 # Parent db93daf4704afb50a2a46ec3beba8c825daac214 -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 diff --git a/src/server/distrend.c b/src/server/distrend.c --- a/src/server/distrend.c +++ b/src/server/distrend.c @@ -155,9 +155,11 @@ int start_data(){ 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) @@ -189,6 +191,7 @@ void mortition(struct distrenjob *head, if(isJobDone) { distrenjob_remove(&head, job); + general_info.jobs_in_queue--; } } @@ -210,6 +213,9 @@ void prepare_distrenjob(struct frameset 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); @@ -314,6 +320,7 @@ int frame_finder(struct distrenjob *head 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; } } @@ -408,6 +415,7 @@ void distrenjob_remove(struct distrenjob */ previous_distrenjob->next = bj->next; } + general_info.jobs_in_queue--; }