Changeset - 454b0844bf6e
[Not reviewed]
default
0 3 0
ethanzonca - 16 years ago 2009-09-02 21:04:32

Added error/404-catching code to the curl_get() function
3 files changed with 18 insertions and 10 deletions:
0 comments (0 inline, 0 general)
TODO
Show inline comments
 
@@ -20,13 +20,14 @@ Master
 
Slave
 
 -Fix current bugs
 
*-Add calls to remoteio, once it works or even before it works
 
 -Add code to write arguments for exec_blender based on the contents of a job's xml file
 
x-Add code to write arguments for exec_blender based on the contents of a job's xml file
 
*-Other XML-writing/reading
 
	+Update exec_blender() to use some struct info, maybe.
 
 -Add errorcatchers to return in libcurl functions, can we detect 404?
 
	+Update exec_blender() to use some struct info, maybe. The struct is being passed to it.
 
x-Add errorcatchers to return in libcurl functions, can we detect 404?
 
=-Make code more flexible for different types of jobs and operating systems (such as paths, libs, etc)
 
 -Add code to allow pausing/resuming of the slave (including a running blender process)
 
 -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)
 

	
 
Options
 
 -Rewrite some stuff, try to make it simpler
src/server/slave.c
Show inline comments
 
@@ -135,7 +135,7 @@ struct distrenjob *myjob; // Structure t
 
if(gotframe ==1)
 
  {
 
    /* @TODO: fix these remoteio_read's */
 
    jobnum = remotio_read(jobnum); // Set jobnum from remoteio (we could use info from struct, but we need this info to download the xmlfile)
 
    jobnum = remoteio_read(jobnum); // Set jobnum from remoteio (we could use info from struct, but we need this info to download the xmlfile)
 
    framenum = remoteio_read(jobnum); // Set framenum from remoteio
 

	
 
    char *tarcmd;
 
@@ -162,14 +162,21 @@ if(gotframe ==1)
 
      int fstatus = stat(pathtoJobfile, &buffer);
 
      if(fstatus != -1){
 
              fprintf(stderr, "Using cached job file...\n");
 
              curlget(urltoTar, pathtoTar); // Downloads the Tar @TODO: add a progressbar
 

	
 
              // Downloads the Tar, with an error catcher. @TODO: add a progressbar
 
              if( curlget(urltoTar, pathtoTar) == 0){
 
                fprintf(stderr, "File downloaded without errors\n");
 
              }
 
              else{
 
                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");
 
              }
 
      }
 

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

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

	
 
@@ -184,7 +191,7 @@ if(gotframe ==1)
 
    }
 

	
 
    /* Variable-fillers which require XML */
 
    outputExt = myjob.outputFormat;
 
    outputExt = myjob.outputFormat; /* @TODO: FIXME! */
 
    _distren_asprintf(&pathtoOutput, "%s/job%d/output/frame%d.%s", datadir, jobnum, framenum, outputExt ); // Prepares the path to the jobfile
 

	
 

	
src/server/slavefuncs.c
Show inline comments
 
@@ -63,7 +63,7 @@ xmlNodePtr xml_quickxpath(xmlXPathContex
 
}
 

	
 

	
 
/** Stub stub stubbiness ugh */
 
/** Stub stub stubbiness ugh @TODO: Kill me. */
 
void tell_the_server(char *stuff){
 
}
 

	
 
@@ -73,7 +73,7 @@ size_t curl_writetodisk(void *ptr, size_
 
    return fwrite(ptr, size, nmemb, stream);
 
  }
 

	
 
/** Gets a URL with cURL and saves it to disk */
 
/** Retrieves a URL with cURL and saves it to disk */
 
int curlget(char *url, char *out){
 
  CURL *curl;
 
  CURLcode res;
 
@@ -89,7 +89,7 @@ int curlget(char *url, char *out){
 
  res = curl_easy_perform(curl);
 
  curl_easy_cleanup(curl);
 
  }
 
  return 0;
 
  return res; // 0 means OK, nonzero means AAAH badness
 
}
 

	
 
/** Posts a file to a url with cUrl */
0 comments (0 inline, 0 general)