diff --git a/src/server/distrend.c b/src/server/distrend.c --- a/src/server/distrend.c +++ b/src/server/distrend.c @@ -156,6 +156,7 @@ void finish_frame(struct distrenjob *dis 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? distrenjob->avg_render_time = ((distrenjob->avg_render_time*(distrenjob->completed_frames - 1)) + distrenjob->frameset[frame].time_to_render)/distrenjob->completed_frames; + distrenjob->completed_frames++; general_info.total_frames_rendered++; // Increase total frames var for stats } @@ -373,65 +374,55 @@ void change_job_priority(struct distrenj @return 0 success, other: error */ +/*@TODO: change frame_finder to job_finder */ int frame_finder(struct distrenjob *head, struct distrenjob **job, struct frameset **frame) { - int your_frame; // your_frame is an integer value that will be given to the client as the frame number to render - + int your_frame = 0; // your_frame is an integer value that will be given to the client as the frame number to render + short int your_job_type = 0; unsigned short int found; - unsigned short int priority; struct distrenjob *distrenjob_ptr; found = 0; + while(!found) + { + /* iterate through jobs from first to last */ + for(distrenjob_ptr = head->next; !found && !distrenjob_ptr; distrenjob_ptr = distrenjob_ptr->next) + { + if(distrenjob_ptr->is_job_done) + distrenjob_ptr->type = your_job_type; + } + + switch(your_job_type) { - /* enumerate through priority levels */ - for(priority = 10; - priority > 0 - && !found; - priority --) - /* Find the job with the highest priority */ - for(distrenjob_ptr = head; - distrenjob_ptr != NULL - && !found; - distrenjob_ptr = distrenjob_ptr->next) - if(distrenjob_ptr->priority == priority) - found = 1; - + case 1: // blender + found = 0; + for(your_frame; !found; your_frame++) + { + if(distrenjob_ptr->frameset[your_frame].status == 0) + { + found = 1; + distrenjob_ptr->frameset[your_frame].status = 1; + distrenjob_ptr->frameset[your_frame].start_time = clock(); + break; + } + } + } + } // end of while statement... job must be found or linked list must be ended to get out of here if(!found) { fprintf(stderr, "No more jobs to render\n"); return 1; } - found = 0; - for(your_frame = 0; - your_frame < distrenjob_ptr->total_frames; - your_frame ++) - if(distrenjob_ptr->frameset[your_frame].status == 0) - found = 1; - - if(!found) - { - /* there are no frames left in this job */ - distrenjob_ptr->priority --; + // the actual frame number to be rendered by the client is start_frame + your_frame + // @TODO: refine how we want to return data from this + //struct framejob { distrenjob_ptr; distrenjob_ptr->(&frameset[your_frame])}; - /* If that job had no open frames for some reason, run the status report generator so that */ - status_report_generator(&head); - - /* should the job be removed now? */ - fprintf(stderr, "Job %d is finished, this is probably the place to call the job-removal function\n", distrenjob_ptr->jobnum); - /* @TODO: At this point, all slaves should be instructed to delete the source data for this job. */ - } - } - - /* Sets the value of the frame to 1, which means it is taken */ - distrenjob_ptr->frameset[your_frame].status++; - - distrenjob_ptr->frameset[your_frame].start_time = clock(); - - *job = distrenjob_ptr; - *frame = &distrenjob_ptr->frameset[your_frame]; + /* should the job be removed now? ANSWER: well, if a computer decides not to return their frame then we lost our data... so its not done yet. */ + fprintf(stderr, "Job %d is finished, this is probably the place to call the job-removal function\n", distrenjob_ptr->jobnum); + /* @TODO: At this point, all slaves should be instructed to delete the source data for this job. */ return 0; }