# HG changeset patch # User ethanzonca # Date 2009-08-03 22:30:02 # Node ID 84c89cf7f4eace1bb14b46821a6a062e656cb738 # Parent b50933ddbb8f62ac6d074a7b84134b67bf273ca8 Standardizness? diff --git a/src/server/slave.c b/src/server/slave.c --- a/src/server/slave.c +++ b/src/server/slave.c @@ -130,65 +130,58 @@ char *pathtoJobfile; // Full path to the // If the slave is getting job info... - if(gotframe ==1) - { - char *tarcmd; - char *outdir; - char *jobdatapath; +if(gotframe ==1) + { + char *tarcmd; + char *outdir; + char *jobdatapath; - fprintf(stderr, "Received %d in job %d, preparing to render...",framenum,jobnum); + fprintf(stderr, "Received %d in job %d, preparing to render...",framenum,jobnum); - /** - Variable Preparation - @todo find where to free() all of these - */ - _distren_asprintf(&jobdatapath, "job%d", jobnum); - _distren_asprintf(&urltoTar, "http://protofusion.org/distren/stor/job%d/job%d.tar.gz",jobnum); // Prepares URL to download from - _distren_asprintf(&pathtoTar, "%s/stor/jobdata/job%d.tar.gz", datadir, jobnum); // Prepares destination to save to + /** + Variable Preparation + @todo find where to free() all of these + */ + _distren_asprintf(&jobdatapath, "job%d", jobnum); + _distren_asprintf(&urltoTar, "http://protofusion.org/distren/stor/job%d/job%d.tar.gz",jobnum); // Prepares URL to download from + _distren_asprintf(&pathtoTar, "%s/stor/jobdata/job%d.tar.gz", datadir, jobnum); // Prepares destination to save to - _distren_asprintf(&pathtoJobfile, "%s/%s/job.blend", datadir, jobdatapath ); // Prepares the path to the jobfile - _distren_asprintf(&urltoOutput, "http://protofusion.org/distren/stor/job%d/output/", jobdatapath ); // Prepares the URL where output is posted - _distren_asprintf(&pathtoOutput, "%s/job%d/output/frame%d.%s", datadir, jobnum, framenum, outputext ); // Prepares the path to the jobfile - + _distren_asprintf(&pathtoJobfile, "%s/%s/job.blend", datadir, jobdatapath ); // Prepares the path to the jobfile + _distren_asprintf(&urltoOutput, "http://protofusion.org/distren/stor/job%d/output/", jobdatapath ); // Prepares the URL where output is posted + _distren_asprintf(&pathtoOutput, "%s/job%d/output/frame%d.%s", datadir, jobnum, framenum, outputext ); // Prepares the path to the jobfile - // = DATAPATH "/stor/jobdata/output.jpg"; /*< ? */ - - // Download the data - - curlget(urltoTar, pathtoTar); // Downloads the Tar @TODO: add a progressbar - + // Download the data + curlget(urltoTar, pathtoTar); // Downloads the Tar @TODO: add a progressbar - _distren_asprintf(&outdir, "/tmp/distren/job%d", jobnum); /*< @todo free() */ - mkdir("/tmp/distren"); - mkdir(outdir); + _distren_asprintf(&outdir, "/tmp/distren/job%d", jobnum); /*< @todo free() */ + mkdir("/tmp/distren"); + mkdir(outdir); - _distren_asprintf(&tarcmd, "tar -xvf \"%s\" -C \"%s\"", pathtoTar, outdir); - system(tarcmd); - free(tarcmd); + _distren_asprintf(&tarcmd, "tar -xvf \"%s\" -C \"%s\"", pathtoTar, outdir); + system(tarcmd); + free(tarcmd); - // exec_blender(blendjob, pathtoJobfile, pathtoOutput, framenum); // So this should grab data from the struct? I have no idea. @TODO: Ohnobinki, we should clear this up. + // exec_blender(blendjob, pathtoJobfile, pathtoOutput, framenum); // So this should grab data from the struct? I have no idea. @TODO: Ohnobinki, we should clear this up. - // Consider placing the following in the exec_blender() function - while(busy == 1){ - tell_the_server(DISTREN_REQUEST_PROGRESS); - fprintf(stderr, "Rendering frame %d in job %d...",framenum,jobnum); - sleep(5); // or not... this should be more event-driven, but should still give a heartbeat to the server - } - busy = 2; - - busy=1; // When done rendering, set this. - } - // When blender is finished, run this... - if(busy==2){ - fprintf(stderr, "Finished frame %d in job %d, uploading...",framenum,jobnum); - char *outputurl; - _distren_asprintf(&outputurl, "http://protofusion.org/distren/stor/job%d/",jobnum); // Throws the jobnum nicely in the string - curlpost(pathtoOutput, urltoOutput); // posts the output at outputpath to the server at outputurl - tell_the_server(DISTREN_REQUEST_DONEFRAME); // AKA "I'm done rendering that frame you sent me" - busy=0; - // Slave now becomes idle, doesn't need to tell the server anything, ssh handles this. - } - + // Consider placing the following in the exec_blender() function + while(busy == 1){ + tell_the_server(DISTREN_REQUEST_PROGRESS); + fprintf(stderr, "Rendering frame %d in job %d...",framenum,jobnum); + sleep(5); // or not... this should be more event-driven, but should still give a heartbeat to the server + } + busy = 2; + busy = 1; // When done rendering, set this. + } + // When blender is finished, run this... + if(busy==2){ + fprintf(stderr, "Finished frame %d in job %d, uploading...",framenum,jobnum); + char *outputurl; + _distren_asprintf(&outputurl, "http://protofusion.org/distren/stor/job%d/",jobnum); // Throws the jobnum nicely in the string + curlpost(pathtoOutput, urltoOutput); // posts the output at outputpath to the server at outputurl + tell_the_server(DISTREN_REQUEST_DONEFRAME); // AKA "I'm done rendering that frame you sent me" + busy=0; + // Slave now becomes idle, doesn't need to tell the server anything, ssh handles this. + } return 0; }