# HG changeset patch # User Binki # Date 2009-11-28 12:59:06 # Node ID 29bb47ae5ba94a7bb137c7557d082eb7fe1b730a # Parent 483a34f1fa5620f521d6b2dd17294cb38841d154 distrend code cleanup, struct general_info not global, fix change_job_priority() A lot of references to the struct general_info had to be fixed. I fixed many chunks of code form as I came upon stuff that made no sense. diff --git a/src/server/distrend.c b/src/server/distrend.c --- a/src/server/distrend.c +++ b/src/server/distrend.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -44,37 +45,43 @@ #include #include +/* local defs */ +#define NUMBER_ELEVEN 11 + /* ******************* Structs ************************ */ -struct general_info { - short int jobs_in_queue; // - unsigned short int free_clients; - unsigned short int rendering_clients;// - unsigned short int total_finished_jobs; // - unsigned int total_frames_rendered; // +struct general_info +{ + struct distrenjob head; + + int jobs_in_queue; + unsigned int free_clients; + unsigned int rendering_clients; + unsigned int total_finished_jobs; + unsigned int total_frames_rendered; unsigned int highest_jobnum; - short int hibernate; - unsigned int timestamp; - unsigned long int total_render_power; - unsigned long int total_priority_pieces; -} general_info; + int hibernate; + time_t timestamp; + unsigned long total_render_power; + unsigned long total_priority_pieces; +}; /* internally defined funcs's prototypes @TODO: Make all functions nice and proper */ -void distrenjob_remove(struct distrenjob *head, struct distrenjob *bj); +void distrenjob_remove(struct general_info *, struct distrenjob *bj); struct distrenjob *distrenjob_get(struct distrenjob *head, jobnum_t jobnum); -void distrenjob_enqueue(struct distrenjob *head, struct distrenjob *job); -void mortition(struct distrenjob *head, struct distrenjob *job); +int distrenjob_enqueue(struct general_info *, struct distrenjob *job); +int mortition(struct general_info *, struct distrenjob *job); int makeJobDataXML(struct distrenjob *job); -int updateJobListXML(struct distrenjob *head); +int update_xml_joblist(struct general_info *); int createQueueFromXML(struct distrenjob *head); int reCreateQueueFromXML(struct distrenjob *head, xmlDocPtr doc, xmlNodePtr current); -void updateGeneralInfo(); -void importGeneralInfo(); +void update_general_info(struct general_info*); +int import_general_info(struct general_info*); int updateJobStatsXML(struct distrenjob *job); @@ -100,51 +107,68 @@ void distrend_action_free() } -/** Fill variables after crash / shutdown from XML dumps */ -int start_data(struct distrenjob *head, char *datadir) +/** + Fill variables at startup from XML dumps or defaults + */ +int start_data(struct general_info *general_info, char *datadir) { struct stat buffer; - if(stat("general_info.xml", &buffer) == 0){ - importGeneralInfo(); + + /** + defaults + */ + memset(&general_info->head, '\0', sizeof(struct distrenjob)); + general_info->head.priority = 0; + + general_info->jobs_in_queue = 0; + general_info->free_clients = 0; + general_info->rendering_clients = 0; + general_info->total_finished_jobs = 0; + general_info->total_frames_rendered = 0; + general_info->highest_jobnum = 0; + general_info->hibernate = 0; + general_info->timestamp = 0; + general_info->total_render_power = 0; + general_info->total_priority_pieces = 0; - fprintf(stderr,"Parsing XML files and restoring previous state...\n"); - createQueueFromXML(head); - return 1; - } - else{ - fprintf(stderr,"Couldn't find XML dump, starting up fresh.\n"); - general_info.total_finished_jobs = 0; - general_info.total_frames_rendered = 0; - general_info.free_clients = 0; - general_info.highest_jobnum = 0; - general_info.jobs_in_queue = 0; - general_info.rendering_clients = 0; - general_info.hibernate = 0; - general_info.timestamp = 0; + fprintf(stderr, "Initialized default global and queue states\n"); + + if(stat("general_info.xml", &buffer) == 0) + { + fprintf(stderr, "previous state file found, loading:\n"); - // Create the stor directory - // char *stor; - // _distren_asprintf(&stor, "%s/stor", datadir); - // mkdir(stor); - return 2; - } + fprintf(stderr, "Parsing XML files and restoring previous state...\n"); + if(import_general_info(general_info)) + fprintf(stderr, "FAILURE\n"); + + fprintf(stderr, "Restoring queue...\n"); + if(createQueueFromXML(&general_info->head)) + fprintf(stderr, "FAILURE\n"); + + fprintf(stderr, "done\n"); + } + + return 0; } /** Finish-Setter: Sets a frame to the "completed" status.*/ -void finish_frame(struct distrenjob *head, struct distrenjob *distrenjob, int frame) +void finish_frame(struct general_info *geninfo, struct distrenjob *distrenjob, int frame) { 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--; - general_info.total_frames_rendered++; // Increase total frames var for stats + distrenjob->completed_frames ++; + distrenjob->assigned_frames --; + geninfo->total_frames_rendered ++; /*< Increase total frames var for stats */ - updateGeneralInfo(); + update_general_info(geninfo); updateJobStatsXML(distrenjob); } -/** "mortition" check to see if a job is actually done by scanning the folder of the job to make sure all frames are present*/ -void mortition(struct distrenjob *head, struct distrenjob *job) +/** + checks to see if a job is actually done. + - scans the folder of the job to make sure all output files are present +*/ +int mortition(struct general_info *geninfo, struct distrenjob *job) { short int isJobDone; int counter; @@ -159,23 +183,25 @@ void mortition(struct distrenjob *head, { job->frameset[counter].status = FRAMESETSTATUS_UNASSIGNED; job->completed_frames--; - general_info.total_frames_rendered--; + geninfo->total_frames_rendered--; isJobDone = 0; // if a missing frame is found, set isJobDone to false } } if(isJobDone) // if all frames were accounted for { - distrenjob_remove(head, job); + distrenjob_remove(geninfo, job); distrenjob_free(&job); - general_info.jobs_in_queue--; - updateJobListXML(head); + geninfo->jobs_in_queue --; + update_xml_joblist(geninfo); } else{ job->prev_frame_index = -1; // if the job isn't done, have frame_finder() start from the first frame, allowing it to see the frames that are now unassigned } - updateGeneralInfo(); + update_general_info(geninfo); + + return 0; } /** scans the frames of a job to initialize a job after server */ @@ -205,7 +231,7 @@ int restoreJobState(struct distrenjob *j } /** creates a structure from starting data, then calls another function to actually add that struct to the queue */ -int prepare_distrenjob(struct distrenjob *head, int type, char *name, char *submitter, char *email, int priority, int start_frame, int end_frame, int width, int height) +int prepare_distrenjob(struct general_info *geninfo, int type, char *name, char *submitter, char *email, int priority, int start_frame, int end_frame, int width, int height) { int counter2; int counter; @@ -217,9 +243,9 @@ int prepare_distrenjob(struct distrenjob if(tmp) return 1; - general_info.highest_jobnum++; + geninfo->highest_jobnum ++; + distrenjob->jobnum = geninfo->highest_jobnum; - distrenjob->jobnum = general_info.highest_jobnum; distrenjob->type = 1; distrenjob->name = name; distrenjob->submitter = submitter; @@ -251,13 +277,13 @@ int prepare_distrenjob(struct distrenjob fprintf(stderr, "\nprepare_distrenjob: attempting makeJobDataXML()\n"); makeJobDataXML(distrenjob); fprintf(stderr, "\nprepare_distrenjob: attempting distrenjob_enqueue()\n"); - distrenjob_enqueue(head, distrenjob); + distrenjob_enqueue(geninfo, distrenjob); - general_info.jobs_in_queue++; - fprintf(stderr, "\nprepare_distrenjob: attempting updateJobListXML()\n"); - updateJobListXML(head); - fprintf(stderr, "\nprepare_distrenjob: attempting updateGeneralInfo()\n"); - updateGeneralInfo(); + geninfo->jobs_in_queue ++; + fprintf(stderr, "\nprepare_distrenjob: attempting update_xml_joblist()\n"); + update_xml_joblist(geninfo); + fprintf(stderr, "\nprepare_distrenjob: attempting update_general_info()\n"); + update_general_info(geninfo); fprintf(stderr, "\nprepare_distrenjob: attempting updateJobStatsXML()\n"); updateJobStatsXML(distrenjob); @@ -266,10 +292,14 @@ int prepare_distrenjob(struct distrenjob /** distrenjob_enqueue: This function adds the job to the queue based on its priority */ -void distrenjob_enqueue(struct distrenjob *head, struct distrenjob *job) +int distrenjob_enqueue(struct general_info *geninfo, struct distrenjob *job) { - struct distrenjob *prev_job = head; // create pointer to previous job - struct distrenjob *current_job; // create pointer to current_job (which job is being compared to) + struct distrenjob *prev_job; + struct distrenjob *current_job; + struct distrenjob *head; + + head = &geninfo->head; + prev_job = head; // iterate through linked list of jobs for(current_job = head->next; 1; current_job = current_job->next) @@ -289,36 +319,45 @@ void distrenjob_enqueue(struct distrenjo prev_job = current_job; } /* for(current_job) */ + + return 0; } /** Changes the priority of an existing (and maybe running) job. @arg head I may end up changing the head if job == head */ -void change_job_priority(struct distrenjob *head, struct distrenjob *job, int new_priority){ - distrenjob_remove(head, job); +int change_job_priority(struct general_info *geninfo, struct distrenjob *job, int new_priority){ + distrenjob_remove(geninfo, job); job->priority = new_priority; struct distrenjob *current_job; - struct distrenjob *prev_job = head; + struct distrenjob *prev_job; + + prev_job = &geninfo->head; if(job->frameset[0].status == FRAMESETSTATUS_UNASSIGNED) - /* if job was not yet started */ - distrenjob_enqueue(head, job); - else{ // if job has already been started, place it before the jobs with the same priority - // iterate through linked list of jobs - for(current_job = head; current_job != NULL; current_job = current_job->next){ - if(current_job == NULL){ // if it has reached the end of the list, add job there - prev_job->next = job; - break; - } - else if(job->priority <= current_job->priority){ // if job's priority is less than or equal to current_job's priority, insert job - prev_job->next = job; // keep in mind 1 is the highest priority given to jobs, head has a - job->next = current_job; // priority of zero so it will always be before other jobs - break; - } + /** + if job was not yet started + */ + { + distrenjob_enqueue(geninfo, job); + return 0; + } + /** + iterate through linked list of jobs + */ + for(current_job = &geninfo->head; + current_job != NULL + && job->priority > current_job->priority; + current_job = current_job->next) prev_job = current_job; - } - } - updateJobListXML(head); + + prev_job->next = job; + job->next = current_job; + + + update_xml_joblist(geninfo); makeJobDataXML(job); // because priority is changed + + return 0; } /** @@ -327,9 +366,9 @@ void change_job_priority(struct distrenj @TODO: Add calls in main() @return 0 success, other: error */ -int find_jobframe(struct distrenjob *head, struct distrenjob **job, struct frameset **frame) +int find_jobframe(struct general_info *geninfo, struct distrenjob **job, struct frameset **frame) { - if(general_info.hibernate) + if(geninfo->hibernate) return 1; unsigned int frame_counter; @@ -339,7 +378,7 @@ int find_jobframe(struct distrenjob *hea found = 0; /* iterate through jobs from first to last */ - for(distrenjob_ptr = head->next; distrenjob_ptr && !distrenjob_ptr->hibernate; distrenjob_ptr = distrenjob_ptr->next) + for(distrenjob_ptr = geninfo->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 ++) { @@ -411,9 +450,9 @@ int find_jobframe_from_job(struct distre } // find a frame to render when the job that the last frame was for no longer exists -int find_jobframe_new(struct distrenjob *head, int rend_pwr, struct distrenjob **job, struct frameset **frame) +int find_jobframe_new(struct general_info *geninfo, int rend_pwr, struct distrenjob **job, struct frameset **frame) { - if(general_info.hibernate) + if(geninfo->hibernate) return 1; float power_difference; @@ -426,13 +465,16 @@ int find_jobframe_new(struct distrenjob greatest_power_difference = -10000; found = 0; /* iterate through jobs from first to last */ - for(distrenjob_ptr = head->next; - distrenjob_ptr && !distrenjob_ptr->hibernate; - distrenjob_ptr = distrenjob_ptr->next) + for(distrenjob_ptr = geninfo->head.next; + distrenjob_ptr && !distrenjob_ptr->hibernate; + distrenjob_ptr = distrenjob_ptr->next) { if(distrenjob_ptr->prev_frame_index < (distrenjob_ptr->total_frames - 1)) { - power_difference = (((float)general_info.total_render_power / (float)general_info.total_priority_pieces)*(11-(float)distrenjob_ptr->priority)); + /** + Why is the number 11 found here again? --ohnobinki + */ + power_difference = (((float)geninfo->total_render_power / (float)geninfo->total_priority_pieces) * (NUMBER_ELEVEN - (float)distrenjob_ptr->priority)); power_difference = power_difference - (float)distrenjob_ptr->assigned_render_power; fprintf(stderr, "job num %d\npower difference: %f\n", distrenjob_ptr->jobnum, power_difference); @@ -459,15 +501,15 @@ int find_jobframe_new(struct distrenjob } // gets a frame to render from the same job that the previously rendered frame was from -int find_jobframe_again(struct distrenjob *head, int jobnum, int rend_pwr, struct distrenjob **job, struct frameset **frame) +int find_jobframe_again(struct general_info *geninfo, int jobnum, int rend_pwr, struct distrenjob **job, struct frameset **frame) { - if(general_info.hibernate) + if(geninfo->hibernate) return 1; short int found; struct distrenjob *distrenjob_ptr; - distrenjob_ptr = distrenjob_get(head, jobnum); + distrenjob_ptr = distrenjob_get(&geninfo->head, jobnum); // if the job was not found or there are no frames left in the job... if(!distrenjob_ptr || distrenjob_ptr->prev_frame_index >= (distrenjob_ptr->total_frames - 1)) @@ -478,14 +520,14 @@ int find_jobframe_again(struct distrenjo if(distrenjob_ptr) distrenjob_ptr->assigned_render_power = distrenjob_ptr->assigned_render_power - rend_pwr; - return find_jobframe_new(head, rend_pwr, job, frame); + return find_jobframe_new(geninfo, rend_pwr, job, frame); } found = 0; found = find_jobframe_from_job(distrenjob_ptr, job, frame); if(found) - find_jobframe_new(head, rend_pwr, job, frame); + find_jobframe_new(geninfo, rend_pwr, job, frame); return 0; } @@ -544,22 +586,22 @@ struct distrenjob *distrenjob_get(struct @arg head pointer to the head of the linkedlist of distrenjobs */ -void distrenjob_remove(struct distrenjob *head, struct distrenjob *bj) +void distrenjob_remove(struct general_info *geninfo, struct distrenjob *bj) { struct distrenjob *previous_distrenjob; - for(previous_distrenjob = head; + for(previous_distrenjob = &geninfo->head; previous_distrenjob && previous_distrenjob->next != bj; /*< stop on the distrenjob that comes before bj */ previous_distrenjob = previous_distrenjob->next) - /* all of the action is in the definition of the for loop itself */; + ; /* 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--; + geninfo->jobs_in_queue --; } @@ -617,7 +659,7 @@ int distrend_config_free(struct distrend // writes the general_info.xml file which is a copy of the general_info structure // except that it doesn't hold free_clients and rendering_clients -void updateGeneralInfo() +void update_general_info(struct general_info *geninfo) { xmlTextWriterPtr writer; char *tmp; @@ -627,13 +669,13 @@ void updateGeneralInfo() xmlTextWriterStartElement(writer, (xmlChar*)"general_info"); - _distren_asprintf(&tmp, "%d", general_info.jobs_in_queue); + _distren_asprintf(&tmp, "%d", geninfo->jobs_in_queue); xmlTextWriterWriteElement(writer, (xmlChar*)"jobs_in_queue", (xmlChar*)tmp); - _distren_asprintf(&tmp, "%d", general_info.total_finished_jobs); + _distren_asprintf(&tmp, "%d", geninfo->total_finished_jobs); xmlTextWriterWriteElement(writer, (xmlChar*)"total_finished_jobs", (xmlChar*)tmp); - _distren_asprintf(&tmp, "%d", general_info.total_frames_rendered); + _distren_asprintf(&tmp, "%d", geninfo->total_frames_rendered); xmlTextWriterWriteElement(writer, (xmlChar*)"total_frames_rendered", (xmlChar*)tmp); - _distren_asprintf(&tmp, "%d", general_info.highest_jobnum); + _distren_asprintf(&tmp, "%d", geninfo->highest_jobnum); xmlTextWriterWriteElement(writer, (xmlChar*)"highest_jobnum", (xmlChar*)tmp); xmlTextWriterEndDocument(writer); @@ -641,7 +683,7 @@ void updateGeneralInfo() } // this reads the information from general_info.xml to the general_info structure -void importGeneralInfo() +int import_general_info(struct general_info *general_info) { xmlDocPtr doc; xmlNodePtr cur; @@ -652,26 +694,28 @@ void importGeneralInfo() { fprintf(stderr, "xml document is wrong type"); xmlFreeDoc(doc); - return; + return 1; } cur = cur->xmlChildrenNode; - general_info.jobs_in_queue = atoi((char*)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)); + general_info->jobs_in_queue = atoi((char*)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)); cur = cur->next; - general_info.total_finished_jobs = atoi((char*)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)); + general_info->total_finished_jobs = atoi((char*)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)); cur = cur->next; - general_info.total_frames_rendered = atoi((char*)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)); + general_info->total_frames_rendered = atoi((char*)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)); cur = cur->next; - general_info.highest_jobnum = atoi((char*)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)); + general_info->highest_jobnum = atoi((char*)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)); - general_info.hibernate = 0; - general_info.free_clients = 0; - general_info.rendering_clients = 0; - general_info.timestamp = 0; - general_info.total_render_power = 0; - general_info.total_priority_pieces = 0; + general_info->hibernate = 0; + general_info->free_clients = 0; + general_info->rendering_clients = 0; + general_info->timestamp = 0; + general_info->total_render_power = 0; + general_info->total_priority_pieces = 0; xmlFreeDoc(doc); + + return 0; } // returns 1 on successful completion of xml file @@ -815,7 +859,7 @@ int updateJobStatsXML(struct distrenjob // returns 1 if successful // updates job_list.xml which lists all the jobs in the queue -int updateJobListXML(struct distrenjob *head) +int update_xml_joblist(struct general_info *geninfo) { struct distrenjob *job; xmlTextWriterPtr writer; @@ -824,9 +868,9 @@ int updateJobListXML(struct distrenjob * int counter; // update timestamp - general_info.timestamp++; - if(general_info.timestamp > 65530) - general_info.timestamp = 0; + geninfo->timestamp ++; + if(geninfo->timestamp > 65530) + geninfo->timestamp = 0; writer = xmlNewTextWriterFilename("job_list.xml", 0); xmlTextWriterStartDocument(writer, NULL, "utf-8", NULL); @@ -834,19 +878,23 @@ int updateJobListXML(struct distrenjob * // create root element job_list xmlTextWriterStartElement(writer, (xmlChar*)"job_list"); - _distren_asprintf(&tmp, "%d", general_info.timestamp); + _distren_asprintf(&tmp, "%d", geninfo->timestamp); xmlTextWriterWriteAttribute(writer, (xmlChar*)"timestamp", (xmlChar*)tmp); - general_info.total_priority_pieces = 0; + geninfo->total_priority_pieces = 0; counter = 0; - for(job = head->next; job; job = job->next) + for(job = geninfo->head.next; job; job = job->next) { _distren_asprintf(&tmp, "jobnum%d", counter); _distren_asprintf(&tmp2, "%d", job->jobnum); xmlTextWriterWriteElement(writer, (xmlChar*)tmp, (xmlChar*)tmp2); - // this is needed for the new frame finder to work - general_info.total_priority_pieces = general_info.total_priority_pieces + (11 - job->priority); + /* + this is needed for the new frame finder to work + + Why the random constant numeral 11? --ohnobinki + */ + geninfo->total_priority_pieces = geninfo->total_priority_pieces + (NUMBER_ELEVEN - job->priority); counter++; } @@ -1022,8 +1070,7 @@ int main(int argc, char *argv[]) int counter; int test; // Interactive test mode if 1 - - struct distrenjob head; + struct general_info general_info; int cont; struct distrend_clientset *clients; @@ -1036,19 +1083,6 @@ int main(int argc, char *argv[]) CLIENTSTATUS_IDLE = 2 } clientstatus; - - // initialize general_info struct, this should be done by start_data() - general_info.jobs_in_queue = 0; - general_info.free_clients = 0; - general_info.rendering_clients = 0; - general_info.total_finished_jobs = 0; - general_info.total_frames_rendered = 0; - general_info.highest_jobnum = 0; - general_info.hibernate = 0; - general_info.timestamp = 0; - general_info.total_render_power = 0; - general_info.total_priority_pieces = 0; - int command; jobnum_t jobnum; struct distrenjob *tmp_job; @@ -1064,8 +1098,6 @@ int main(int argc, char *argv[]) int end_frame; size_t read_buf; - head.priority = 0; // make head have the highest priority - xmlinit(); test = 0; @@ -1084,16 +1116,18 @@ int main(int argc, char *argv[]) } } cont = 1; - memset(&head, '\0', sizeof(struct distrenjob)); - distrend_do_config(argc, argv, &config); - //start_data(&head); // Starts fresh or loads data from xml dump. Should we grab the return? + if(start_data(&general_info, config->datadir)) + { + fprintf(stderr, "%s:%d: start_data() failed\n", __FILE__, __LINE__); + return 1; + } // pre-loaded jobs for testing - prepare_distrenjob(&head, 1, "awesome", "LordOfWar", "onlylordofwar@gmail.com", 8, 1, 100, 640, 480); - prepare_distrenjob(&head, 1, "hamburger", "Ohnobinki", "ohnobinki@ohnopublishing.net", 3, 1, 50, 1280, 720); + prepare_distrenjob(&general_info, 1, "awesome", "LordOfWar", "onlylordofwar@gmail.com", 8, 1, 100, 640, 480); + prepare_distrenjob(&general_info, 1, "hamburger", "Ohnobinki", "ohnobinki@ohnopublishing.net", 3, 1, 50, 1280, 720); while(test == 1) { @@ -1114,16 +1148,16 @@ int main(int argc, char *argv[]) case 1: fprintf(stderr, "Job number: "); scanf("%d", &jobnum); - printJob(distrenjob_get(&head, jobnum)); + printJob(distrenjob_get(&general_info.head, jobnum)); break; case 2: fprintf(stderr, "Job number: "); scanf("%d", &jobnum); - printJobInfo(distrenjob_get(&head, jobnum)); + printJobInfo(distrenjob_get(&general_info.head, jobnum)); break; case 3: - general_info.total_render_power++; - if(!find_jobframe_again(&head, -1, 1, &tmp_job, &tmp_frame)) + general_info.total_render_power ++; + if(!find_jobframe_again(&general_info, -1, 1, &tmp_job, &tmp_frame)) { fprintf(stderr, "frame was found, details below\n"); fprintf(stderr, "Job#:%d\n", tmp_job->jobnum); @@ -1145,21 +1179,21 @@ int main(int argc, char *argv[]) fprintf(stderr, "\nEnd frame: "); scanf("%d", &end_frame); fprintf(stderr, "\nWidth: "); scanf("%d", &width); fprintf(stderr, "\nHeight: "); scanf("%d", &height); - prepare_distrenjob(&head, type, name, submitter, email, priority, start_frame, end_frame, width, height); + prepare_distrenjob(&general_info, type, name, submitter, email, priority, start_frame, end_frame, width, height); break; case 5: fprintf(stderr, "\nJob number: "); scanf("%d", &jobnum); - distrenjob_remove(&head, distrenjob_get(&head, jobnum)); + distrenjob_remove(&general_info, distrenjob_get(&general_info.head, jobnum)); break; case 6: - printAllJobnums(&head); + printAllJobnums(&general_info.head); break; case 7: fprintf(stderr, "\nHighest job number: %d", general_info.highest_jobnum); fprintf(stderr, "\nJobs in queue: %d", general_info.jobs_in_queue); fprintf(stderr, "\nTotal frames rendered: %d", general_info.total_frames_rendered); - fprintf(stderr, "\nTimestamp: %d", general_info.timestamp); + fprintf(stderr, "\nTimestamp: %lu", (long)general_info.timestamp); fprintf(stderr, "\nTotal priority pieces: %ld", general_info.total_priority_pieces); fprintf(stderr, "\nTotal render power: %ld\n", general_info.total_render_power); break; @@ -1182,7 +1216,7 @@ int main(int argc, char *argv[]) cont = distrend_do(action); /* Make the following code more event-driven */ - frame_watchdog(&head); + frame_watchdog(&general_info.head); struct frameset *frame; @@ -1191,7 +1225,7 @@ int main(int argc, char *argv[]) /* If the client is idle, must be modified for climbing through linked list of clients (client->clientnum) */ if(clientstatus == CLIENTSTATUS_IDLE) { - int returnnum = find_jobframe(&head, &job, &frame); // Finds a frame to render + int returnnum = find_jobframe(&general_info, &job, &frame); // Finds a frame to render if(returnnum) { fprintf(stderr,"No frames are available to render at this time. Idling...\n"); @@ -1203,7 +1237,7 @@ int main(int argc, char *argv[]) /* If the client states that they finished the frame */ if(clientsays == DISTREN_REQUEST_DONEFRAME){ clientstatus = CLIENTSTATUS_IDLE; // Sets the client back to idle - finish_frame(&head, job, frame->num); // @TODO: Make sure this actually works. + finish_frame(&general_info, job, frame->num); // @TODO: Make sure this actually works. } distrend_action_free(action);