diff --git a/src/server/distrend.c b/src/server/distrend.c --- a/src/server/distrend.c +++ b/src/server/distrend.c @@ -383,18 +383,28 @@ int find_jobframe(struct distrenjob *hea your_job_type = 0; found = 0; /* iterate through jobs from first to last */ - for(distrenjob_ptr = head->next; (!found && distrenjob_ptr) && !distrenjob_ptr->hibernate; distrenjob_ptr = distrenjob_ptr->next) - for(frame_counter = (distrenjob_ptr->prev_frame_index + 1); !found && frame_counter < distrenjob_ptr->total_frames; frame_counter ++) + for(distrenjob_ptr = head->next; distrenjob_ptr && !distrenjob_ptr->hibernate; distrenjob_ptr = distrenjob_ptr->next) + { + for(frame_counter = (distrenjob_ptr->prev_frame_index + 1); frame_counter < distrenjob_ptr->total_frames; frame_counter ++) + { if(distrenjob_ptr->frameset[frame_counter].status == FRAMESETSTATUS_UNASSIGNED) // jobframe found - { - found = 1; - your_job_type = distrenjob_ptr->type; - distrenjob_ptr->frameset[frame_counter].status = FRAMESETSTATUS_ASSIGNED; - distrenjob_ptr->frameset[frame_counter].start_time = clock(); - distrenjob_ptr->assigned_frames++; - distrenjob_ptr->prev_frame_index = frame_counter; - updateJobStatsXML(distrenjob_ptr); - } + { + found = 1; + your_job_type = distrenjob_ptr->type; + distrenjob_ptr->frameset[frame_counter].status = FRAMESETSTATUS_ASSIGNED; + distrenjob_ptr->frameset[frame_counter].start_time = clock(); + distrenjob_ptr->assigned_frames++; + distrenjob_ptr->prev_frame_index = frame_counter; + updateJobStatsXML(distrenjob_ptr); + } + + if(found) + break; + } + + if(found) + break; + } if(!found) { @@ -402,7 +412,7 @@ int find_jobframe(struct distrenjob *hea sleep(1); /*< @todo eliminate the need for this line*/ return 1; } - fprintf(stderr, "jobnum: %d", frame_counter); + *job = distrenjob_ptr; *frame = &distrenjob_ptr->frameset[frame_counter]; @@ -1020,7 +1030,7 @@ int main(int argc, char *argv[]) printJobInfo(distrenjob_get(&head, jobnum)); break; case 3: - if(find_jobframe(&head, &tmp_job, &tmp_frame)) + if(!find_jobframe(&head, &tmp_job, &tmp_frame)) { fprintf(stderr, "frame was found, details below\n"); fprintf(stderr, "Job#:%d\n", tmp_job->jobnum);