Changeset - 52ec1f76eeb7
[Not reviewed]
default
0 2 0
ethanzonca - 16 years ago 2009-09-03 22:10:38

Formatting a few decent fixes, and comment editing
2 files changed with 20 insertions and 19 deletions:
0 comments (0 inline, 0 general)
TODO
Show inline comments
 
@@ -27,6 +27,7 @@ Slave
 
 -Add a threads variable for software that doesn't support threads (blender takes care of this by itself)
 
*-Fix line 194 (call to myjob struct that fails miserably)
 
B-Add tmpdir variable (just like the datadir variable) that is compile-time or whatever
 
*-Add code to delete old jobfiles (maybe based on timestamp, etc... make sure they're uploaded first)
 

	
 
Options
 
 -Rewrite some stuff, try to make it simpler
src/server/slave.c
Show inline comments
 
@@ -113,15 +113,15 @@ options_init(argc,argv,&my_cfg, myopts, 
 

	
 

	
 

	
 
/* Code-filled Vars, filled somewhere in the loopage  */
 
int jobnum;
 
int framenum; // @TODO: Remotio should fill this
 
/* Code-filled Variables  */
 
int jobnum;          // The job number that we're currently working
 
int framenum;        // @TODO: Remotio should fill this
 

	
 
int gotframe; // set this to 1 after data for a job is received from the server
 
int busy = 0;     // Client business 1=busy 0=idle
 
int gotframe;        // set this to 1 after data for a job is received from the server
 
int busy = 0;        // Client business 1=busy 0=idle
 

	
 
char *urltoTar;  // Full URL to the server-side location of job#.tgz
 
char *pathtoTar; // Full path to the location of the job#.tgz
 
char *urltoTar;      // Full URL to the server-side location of job#.tgz
 
char *pathtoTar;     // Full path to the location of the job#.tgz
 

	
 
char *urltoOutput;   // Full URL where output is posted
 
char *pathtoJobfile; // Full path to the job's main file
 
@@ -156,14 +156,11 @@ if(gotframe ==1)
 
    _distren_asprintf(&urltoOutput, "http://protofusion.org/distren/stor/job%d/output/", jobdatapath ); // Prepares the URL where output is posted
 
    _distren_asprintf(&pathtoXml, "%s/job%d/job%d.xml",datadir, jobnum ); // Prepares the path to the job's XML file
 

	
 
    //  Download the data if it isn't  present. (prevents re-downloading for same-job frames) @TODO: Delete old job data
 

	
 
      // Downloads the job tar if it isn't  present. @TODO: Delete old job data
 
      struct stat buffer;
 
      int fstatus = stat(pathtoJobfile, &buffer);
 
      if(fstatus != -1){
 
              fprintf(stderr, "Using cached job file...\n");
 

	
 
              // Downloads the Tar, with an error catcher. @TODO: add a progressbar
 
              // Downloads the Tar @TODO: add progress bar
 
              if( curlget(urltoTar, pathtoTar) == 0){
 
                fprintf(stderr, "File downloaded without errors\n");
 
              }
 
@@ -171,19 +168,22 @@ if(gotframe ==1)
 
                fprintf(stderr, "Download tar from server failed. Either the server is down, or the job hosting system is screwed up.\nContact admin@protofusion.org and include this message.\nGoodbye. Better luck next time.\n");
 
              }
 
      }
 
      else{
 
        fprintf(stderr, "Using cached job file...\n");
 
      }
 

	
 
    _distren_asprintf(&outdir, "/tmp/distren/job%d", jobnum); /*< @todo free() */
 
    mkdir("/tmp/distren", 0750); /* @TODO: This is a tad unix-specific... */
 
    mkdir("/tmp/distren", 0750); /* @TODO: Make this less *nix-specific */
 
    mkdir(outdir, 0750);
 

	
 
    _distren_asprintf(&tarcmd, "tar -xvf \"%s\" -C \"%s\"", pathtoTar, outdir); /* @TODO: Make this portable. Libtar or something? */
 
    system(tarcmd);
 
    free(tarcmd);
 

	
 
    // Grabs data from the XML file, throws it in the myjob struct.
 
    // Parses a job's XML file, puts data in the myjob struct
 
    if(xml2distrenjob(&myjob, pathtoXml) == 0){
 
      fprintf(stderr,"Well, the XML craziness may have worked. Maybe. \n");
 
      distrenjob_free(&myjob); // Frees things up if it was successful. xml2distrenjob() really only fails if malloc'ing inside it fails
 
      distrenjob_free(&myjob); // Frees things up if it was successful. xml2distrenjob() really (usually) only fails if malloc'ing inside it fails
 
    }
 
    else{
 
      fprintf(stderr,"I think the XML craziness may have failed, so I'll terminate just for fun.\n");
 
@@ -204,15 +204,15 @@ if(gotframe ==1)
 
        sleep(5); // or not... this should be more event-driven, but should still give a heartbeat to the server
 
      }
 
    busy = 2;
 
    busy = 1; // @TODO: When done rendering, set this.
 
    // busy = 1; // @TODO: 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"
 
        _distren_asprintf(&outputurl, "http://protofusion.org/distren/stor/job%d/",jobnum); // Aggregates the output url
 
        curlpost(pathtoOutput, urltoOutput); // uploads (HTML POST) the output at outputpath to the server at outputurl
 
        tell_the_server(DISTREN_REQUEST_DONEFRAME); // Tells the server that it's finished rendering this frame
 
        busy=0;
 
        // Slave now becomes idle, doesn't need to tell the server anything, ssh handles this.
 
      }
0 comments (0 inline, 0 general)