diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -45,7 +45,7 @@ AC_TYPE_SIZE_T PKG_PROG_PKG_CONFIG(0.17.2) -PKG_CHECK_MODULES(DISTLIBS, libconfuse >= 2.6 libcurl) +PKG_CHECK_MODULES(DISTLIBS, libconfuse >= 2.6 libcurl libxml-2.0) PKG_CHECK_MODULES([CHECK], [check >= 0.9.4]) AC_DEFINE_DIR([SYSCONFDIR], [sysconfdir], [Directory to find configuration files in]) diff --git a/src/server/distrend.c b/src/server/distrend.c --- a/src/server/distrend.c +++ b/src/server/distrend.c @@ -92,11 +92,11 @@ struct distrend_config */ 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; // + 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; // } general_info; @@ -131,14 +131,14 @@ int distrend_do() */ void distrend_accept() { - + } /** - Frees the action + Frees the action */ void distrend_action_free() { - + } /** Start listening @@ -148,7 +148,7 @@ void distrend_listen() } /** - Stop listening + Stop listening */ void distrend_unlisten() { @@ -163,17 +163,16 @@ void remotio_send_to_client() } /** Fill variables after crash / shutdown from XML dumps */ void start_data(){ - - if(1 == 0){ - // retrieve total_finished_jobs and total_finished_frames from xml file - } - else{ - general_info.total_finished_jobs = 0; - general_info.total_frames_rendered = 0; - } + if(1 == 0){ + // retrieve total_finished_jobs and total_finished_frames from xml file + } + else{ + general_info.total_finished_jobs = 0; + general_info.total_frames_rendered = 0; + } } -// **** Finish-Setter: Sets a frame to the "completed" status. +/** Finish-Setter: Sets a frame to the "completed" status.*/ void finish_frame(struct blendjob *blendjob, int frame){ blendjob->frameset[frame].status = 2; blendjob->frameset[frame].time_to_render = (clock() - blendjob[jobnum].frameset[frame].start_time); // Consider changing time-to-render to time-for-frame or something? @@ -182,11 +181,11 @@ void finish_frame(struct blendjob *blend } -// **** Queuer: Adds files to the queue +/** Queuer: Adds files to the queue */ void queue(struct blendjob *blendjob, int type, char *name, char *submitter, char *email, int priority, int mode, int spp, struct frameset *frameset) { - // Type: 1 = blender, add more types later - // jobnum is the next available job number - if(type == 1){ + // Type: 1 = blender, add more types later + // jobnum is the next available job number + if(type == 1){ blendjob->name = name; blendjob->submitter = submitter; blendjob->email = email; @@ -293,23 +292,23 @@ void status_report_generator(struct blen } -// **** Structure Builder: This function creates frame array based on the total number of frames to be rendered, which will then be parsed by function frame_farmer. +/** Structure Builder: This function creates frame array based on the total number of frames to be rendered, which will then be parsed by function frame_farmer. */ void frame_num_struct_builder(struct blendjob *job, unsigned int startframe, unsigned int numframes) { int jobnum_new = highest_jobnum + 1; /* global vars will someday leave us */ unsigned int counter; - job->frameset = malloc(sizeof(struct frameset) * numframes); - if(!job->frameset) - fprintf(stderr, "error allocating memory"); + job->frameset = malloc(sizeof(struct frameset) * numframes); + if(!job->frameset) + fprintf(stderr, "error allocating memory"); - job->total_frames = numframes; // sets the total number of frames in animation for status purposes - job->jobnum = jobnum_new; + job->total_frames = numframes; // sets the total number of frames in animation for status purposes + job->jobnum = jobnum_new; - for(counter = 0; counter < numframes; counter ++) - /* This builds the array, with the array starting at zero and the frameset.num starting at sframe */ - job->frameset[counter].num = counter + startframe; + for(counter = 0; counter < numframes; counter ++) + /* This builds the array, with the array starting at zero and the frameset.num starting at sframe */ + job->frameset[counter].num = counter + startframe; - highest_jobnum++; // After it has created the job, it adds one to the highest_jobnum interger + highest_jobnum++; // After it has created the job, it adds one to the highest_jobnum interger } @@ -338,41 +337,41 @@ int frame_finder(struct blendjob *head, { /* enumerate through priority levels */ for(priority = 10; - priority > 0 - && !found; - priority --) + priority > 0 + && !found; + priority --) /* Find the job with the highest priority */ - for(blendjob_ptr = head; - blendjob_ptr != NULL - && !found; - blendjob_ptr = blendjob_ptr->next) - if(blendjob_ptr->priority == priority) + for(blendjob_ptr = head; + blendjob_ptr != NULL + && !found; + blendjob_ptr = blendjob_ptr->next) + if(blendjob_ptr->priority == priority) found = 1; if(!found) - { - fprintf(stderr, "out of jobs to render\n"); - return 1; - } + { + fprintf(stderr, "out of jobs to render\n"); + return 1; + } found = 0; for(your_frame = 0; - your_frame < blendjob_ptr->total_frames; - your_frame ++) - if(blendjob_ptr->frameset[your_frame].status == 0) - found = 1; + your_frame < blendjob_ptr->total_frames; + your_frame ++) + if(blendjob_ptr->frameset[your_frame].status == 0) + found = 1; if(!found) - { - /* there are no frames left in this job */ - blendjob_ptr->priority --; + { + /* there are no frames left in this job */ + blendjob_ptr->priority --; /* If that job had no open frames for some reason, run the status report generator so that */ - status_report_generator(&head); + 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", blendjob_ptr->jobnum); - } + /* should the job be removed now? */ + fprintf(stderr, "Job %d is finished, this is probably the place to call the job-removal function\n", blendjob_ptr->jobnum); + } } /* while(!found) */ fprintf(stderr, "Missing apostrophe !!!!!!!!!!!!!!\n"); abort(); @@ -387,6 +386,7 @@ int frame_finder(struct blendjob *head, return 0; } +/** Checks for dying slaves */ void blend_frame_watchdog(struct blendjob *blendjob_head) { unsigned short int watchdog_forgiveness; /*< seconds to wait on a frame before re-assigning it */ @@ -402,12 +402,12 @@ void blend_frame_watchdog(struct blendjo for(counter = 0; counter < blendjob_ptr->total_frames; counter ++) /* iterate through all frames for this job*/ { - if((blendjob_ptr->frameset[counter].start_time + (watchdog_forgiveness * 3600)) < clock()) - /* - If frame is not completed within the number of hours specified by watchdog_forgiveness - Then change the frame status to unassigned - */ - blendjob_ptr->frameset[counter].status = 0; + if((blendjob_ptr->frameset[counter].start_time + (watchdog_forgiveness * 3600)) < clock()) + /* + If frame is not completed within the number of hours specified by watchdog_forgiveness + Then change the frame status to unassigned + */ + blendjob_ptr->frameset[counter].status = 0; } } @@ -426,7 +426,7 @@ struct blendjob *blendjob_get(struct ble */ for(blendjob_ptr = head; blendjob_ptr - && blendjob_ptr->jobnum != jobnum; + && blendjob_ptr->jobnum != jobnum; blendjob_ptr = blendjob_ptr->next); return blendjob_ptr; @@ -448,9 +448,9 @@ void blendjob_remove(struct blendjob **h { for(previous_blendjob = *head; - previous_blendjob - && previous_blendjob->next != bj; /*< stop on the blendjob that comes before bj */ - previous_blendjob = previous_blendjob->next) + previous_blendjob + && previous_blendjob->next != bj; /*< stop on the blendjob that comes before bj */ + previous_blendjob = previous_blendjob->next) /* all of the action is in the definition of the for loop itself */; /* @@ -482,28 +482,28 @@ int distrend_do_config(int argc, char *a cfg_opt_t myopts[] = { CFG_SEC("listen", /* this must be imported into struct listens (which must still be declared) */ - myopts_listen, - CFGF_MULTI), + myopts_listen, + CFGF_MULTI), CFG_SIMPLE_STR("datadir", NULL), CFG_END() }; - + fprintf(stderr, "%s:%d running config\n", __FILE__, __LINE__); *config = malloc(sizeof(struct distrend_config)); myopts[1].simple_value = &(*config)->datadir; - + options_init(argc, argv, &(*config)->mycfg, myopts, "server", &(*config)->options); - fprintf(stderr, "using %s as datadir\n", (*config)->datadir); - + fprintf(stderr, "using %s as datadir\n", (*config)->datadir); + return 0; } int distrend_config_free(struct distrend_config *config) { options_free(config->options); free(config); - + return 0; } // End non-working framework? @@ -511,7 +511,7 @@ int distrend_config_free(struct distrend int main(int argc, char *argv[]) { - /* TODO: Put some arg-grabbing code here */ + /* @TODO: Put some arg-grabbing code here */ struct blendjob *head; @@ -519,6 +519,8 @@ int main(int argc, char *argv[]) struct distrend_listenset *listenset; struct distrend_config *config; + start_data(); // Starts fresh or loads data from xml dump + enum clientstatus { CLIENTSTATUS_UNINITIALIZED = 0, @@ -541,10 +543,7 @@ int main(int argc, char *argv[]) distrend_accept(&action); cont = distrend_do(action); - - /* Somewhat Pseudo-code for basic server operation, should be more event-driven */ - - start_data(); + /* Make the following code more event-driven */ status_report_generator(&head); blend_frame_watchdog(head); @@ -552,33 +551,26 @@ int main(int argc, char *argv[]) struct frameset *frame; struct blendjob *job; - /* If the client is idle (meaning a client without the "busy" status connected via ssh), all clients should be idle by default. */ + /* If the client is idle, must be modified for climbing through linked list of clients (client->clientnum) */ if(clientstatus == CLIENTSTATUS_IDLE) { - /** - normaldotcom: learn about ``return by pointer'' - */ - int returnnum = frame_finder(head, &job, &frame); // give framefinder args, framefinder should return job number and frame number somehow + int returnnum = frame_finder(head, &job, &frame); // Finds a frame to render if(returnnum) { - fprintf(stderr,"No frames are available to render at this time"); + fprintf(stderr,"No frames are available to render at this time. Idling...\n"); sleep(10); } else /* returnnum == 0 */ - remotio_send_to_client(frame->num, job->jobnum); // Did you actually make this function, ohnobinki? --normaldotcom + remotio_send_to_client(frame->num, job->jobnum); // Pseudo-sends data to client } /* 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(jobnum, framenumprevious); // make it finish the previous frame or something, why framenumprevios? Is that the whole linked list thing coming in? - finish_frame(head, jobnum); // @TODO: update so it fits the purpose of the previous line + clientstatus = CLIENTSTATUS_IDLE; // Sets the client back to idle + finish_frame(head, frame->num); // @TODO: Check that finish_frame really gets the jobnum somehow } - /* End Somewhat Pseudo-code */ - - distrend_action_free(action); }