diff --git a/src/server/distrend.c b/src/server/distrend.c --- a/src/server/distrend.c +++ b/src/server/distrend.c @@ -109,6 +109,7 @@ int main(int argc, char *argv[]) CLIENTSTATUS_IDLE = 2 } clientstatus; + clientstatus = CLIENTSTATUS_UNINITIALIZED; // xmlinit(); for(counter = 0; counter < argc; counter ++) @@ -161,26 +162,31 @@ int main(int argc, char *argv[]) /* Make the following code more event-driven */ frame_watchdog(&general_info.head); - struct frameset *frame; + struct frameset frame; struct distrenjob *job; + distrenjob_new(&job); + + memset(&frame, '\0', sizeof(frame)); /* 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(general_info.conn, slaveKey, &job->jobnum, &frame->num); // Finds a frame to render @FIXME: Slavenum :D + int returnnum = find_jobframe(general_info.conn, slaveKey, &job->jobnum, &frame.num); // Finds a frame to render @FIXME: Slavenum :D if(returnnum) { fprintf(stderr,"No frames are available to render at this time. Idling...\n"); sleep(10); } else - remotio_send_to_client(frame->num, job->jobnum); // Pseudo-sends data to client + 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(general_info.conn, 0, job->jobnum, frame->num); // @TODO: Make sure this actually works. - } + if(clientsays == DISTREN_REQUEST_DONEFRAME) + { + clientstatus = CLIENTSTATUS_IDLE; // Sets the client back to idle + finish_frame(general_info.conn, 0, job->jobnum, frame.num); // @TODO: Make sure this actually works. + } + distrenjob_free(&job); } distrend_unlisten(general_info.config->listens, clients);