Changeset - d231345767d5
[Not reviewed]
default
0 4 0
Ethan Zonca (ethanzonca) - 15 years ago 2010-09-13 17:04:23
e@ethanzonca.com
Added output extension and resolution support in render calls and _web calls, breaks slave.c
4 files changed with 52 insertions and 15 deletions:
0 comments (0 inline, 0 general)
distrensimpleslave-init
Show inline comments
 
@@ -10,11 +10,11 @@
 
. /etc/rc.d/init.d/functions
 

	
 
prog="DistRen SimpleSlave"
 
process="distrensimpleslave"i
 
process="distrensimpleslave"
 
args=""
 

	
 
logfile="/var/log/distrensimpleslave"
 
binary="/usr/bin/distrensimpleslave $args 2>$logfile &"
 
binary="/usr/local/bin/distrensimpleslave $args 2>$logfile &"
 
lockfile="/var/lock/subsys/distrensimpleslave"
 

	
 
start() {
src/server/simpleslave.c
Show inline comments
 
@@ -155,6 +155,8 @@ if(updateConf){
 
  // Variables needed for main loop
 
  int jobnum = 0;
 
  int framenum = 0;
 
  int xres = 0;
 
  int yres = 0;
 
  int slavekey = atoi(username); // @TODO: Make this more friendly
 

	
 
  char *urltoTar;      /* Full URL to the server-side location of job#.tgz */
 
@@ -210,7 +212,7 @@ if(updateConf){
 
    // request work
 
    if(DEBUG)
 
      fprintf(stderr,"Requesting work from %s...\n", hostname);
 
    haveWork = _web_getwork(slavekey, password, &jobnum, &framenum);
 
    haveWork = _web_getwork(slavekey, password, &jobnum, &framenum, &xres, &yres, outputExt);
 

	
 
    /* If we got a frame */
 
    if(haveWork)
 
@@ -277,8 +279,7 @@ if(updateConf){
 
          fprintf(stderr,"Executing blender on file %s\n", pathtoJobfile);
 
          fprintf(stderr,"Directing output to file %s\n", pathtoOutput);
 
        }
 

	
 
        if(exec_blender(pathtoJobfile, pathtoRenderOutput, framenum))
 
        if(exec_blender(pathtoJobfile, pathtoRenderOutput, outputExt, xres, yres, framenum))
 
          {
 
            fprintf(stderr,"Error running Blender. Check your installation and/or your PATH.\n");
 
            _web_resetframe(slavekey, password, jobnum, framenum);  // Unassign the frame on the server so other slaves can render it
src/server/slavefuncs.c
Show inline comments
 
@@ -34,6 +34,7 @@
 
#include <archive.h>
 
#include <archive_entry.h>
 

	
 
#include <ctype.h>
 
#include <errno.h>
 
#include <stdio.h>
 
#include <string.h>
 
@@ -48,6 +49,11 @@
 
#define DEBUG 0
 

	
 

	
 
void stringToUpper(char *string){
 
  while(*string != '\0') {
 
    *string = toupper((unsigned char)*string);
 
  }
 
}
 

	
 
/**
 
   Grabs the xml DOM node reached by an XPath.
 
@@ -258,14 +264,23 @@ return 1; // Success
 
/* Executors */
 

	
 
/** Executor function for Blender operations */
 
int exec_blender(char *input, char *output, int frame)
 
int exec_blender(char *input, char *output, char *outputExt, int xres, int yres, int frame)
 
{
 
  int ret;
 

	
 
  stringToUpper(outputExt);
 

	
 
  char *frame_str;
 
  _distren_asprintf(&frame_str, "%i", frame);
 

	
 
  char *xres_str;
 
  _distren_asprintf(&xres_str, "%i", xres);
 

	
 
  char *yres_str;
 
  _distren_asprintf(&yres_str, "%i", yres);
 

	
 
  char *command = "blender"; // @TODO: We currently expect this to be in PATH
 
  char *cmd[] = { command, "-b", input, "-o", output, "-f", frame_str, "-t", "0", (char *)NULL }; // arguments for blender
 
  char *cmd[] = { command, "-b", input, "-o", output, "-F", outputExt, "-f", frame_str, "-t", "0", (char *)NULL }; // arguments for blender
 

	
 
  if(DEBUG)
 
    fprintf(stderr,"Preparing to execute command: %s -b %s -o %s -f %s\n", command, input, output, frame_str);
 
@@ -649,7 +664,8 @@ void _web_startframe(int slavekey, char 
 
    free(data.memory);
 
}
 

	
 
int _web_getwork(int slavekey, char *slavepass, int *jobnum, int *framenum){
 
/** @TODO: Needs to get xres, yres, outpuext */
 
int _web_getwork(int slavekey, char *slavepass, int *jobnum, int *framenum, int *xres, int *yres, char *outputext){
 
  char *url;
 
  _distren_asprintf(&url,"http://distren.org/slave/act.php?mode=getwork&slavekey=%d&slavepass=%s", slavekey, slavepass);
 
  struct _web_memorystruct data = _web_getrequest(url);
 
@@ -660,12 +676,12 @@ int _web_getwork(int slavekey, char *sla
 
    return 0;
 
  }
 
  else if(!strcmp(data.memory, "ERROR_BADKEY")){
 
    fprintf(stderr,"*** Slave %d does not exist!\n",slavekey);
 
    fprintf(stderr,"*** Slave %d does not exist! Check your slave ID, or register your slave on distren.org\n",slavekey);
 
    free(data.memory);
 
    return 0;
 
  }
 
  else if(!strcmp(data.memory, "ERROR_NORENDERPOWER")){
 
    fprintf(stderr,"*** Render power not set! Please invoke distrensimpleslave -r to run the benchmark!\n",slavekey);
 
    fprintf(stderr,"*** Render power not set! Please invoke distrensimpleslave -r to run the benchmark!\n");
 
    free(data.memory);
 
    return 0;
 
  }
 
@@ -675,17 +691,36 @@ int _web_getwork(int slavekey, char *sla
 
    char *serverversion;
 

	
 
    tmp = strtok (data.memory,",,");
 
    if(tmp != NULL){ // make sure work is available
 
      *jobnum = atoi(tmp);
 
    if(tmp != NULL) { // make sure work is available
 
      *jobnum = atoi(tmp); // Grab jobnum
 

	
 
      tmp = strtok (NULL, ",");
 
      if(tmp == NULL)
 
        return 0; // no work
 
      *framenum = atoi(tmp);
 
      *framenum = atoi(tmp); // Grab framenum
 

	
 
      tmp = strtok (NULL, ",");
 
      if(tmp == NULL)
 
        return 0; // no work
 
      serverversion = tmp;
 

	
 
      tmp = strtok (NULL, ",");
 
      if(tmp == NULL)
 
        return 0; // no work
 
      *xres = atoi(tmp);
 

	
 
      tmp = strtok (NULL, ",");
 
      if(tmp == NULL)
 
        return 0; // no work
 
      *yres = atoi(tmp);
 

	
 
      tmp = strtok (NULL, ",");
 
      if(tmp == NULL)
 
        return 0; // no work
 
      outputext = tmp;
 

	
 
      // @FIXME: Setting outputext and serverversion = temp; will this cause issues as these are pointers to parts of the original temp var?
 

	
 
      // @TODO: This should be called every time, not just on fail.
 
      if(strcmp(PACKAGE_VERSION,serverversion)){
 
        fprintf(stderr,"Your distren package is out of date! Please acquire a newer version. (%s local vs %s remote)\n", PACKAGE_VERSION, serverversion);
src/server/slavefuncs.h
Show inline comments
 
@@ -30,6 +30,7 @@
 

	
 

	
 
struct msg;
 
void stringToUpper(char *string);
 
int sendSignal(struct remoteio *rem, char signal);
 
int sendExtSignal(struct remoteio *rem, char signal, char *data);
 
xmlNodePtr xml_quickxpath(xmlXPathContextPtr xpathctxt, xmlChar *path);
 
@@ -42,7 +43,7 @@ int ssh_keygen();
 
int register_user(char *username, char *email);
 
int login_user(char *username);
 
int conf_replace(char *conffile, char *wordtoreplace, char *replacewith);
 
int exec_blender(char *input, char *output, int frame);
 
int exec_blender(char *input, char *output, char *outputExt, int xres, int yres, int frame);
 
void xmlinit();
 
void xmlcleanup();
 
int distren_mkdir_recurse(const char *dirname);
 
@@ -72,7 +73,7 @@ struct _web_memorystruct _web_getrequest
 
void _web_finishframe(int slavekey, char *slavepass, int jobnum, int framenum);
 
void _web_startframe(int slavekey, char *slavepass, int jobnum, int framenum);
 
void _web_resetframe(int slavekey, char *slavepass, int jobnum, int framenum);
 
int _web_getwork(int slavekey, char *slavepass, int *jobnum, int *framenum);
 
int _web_getwork(int slavekey, char *slavepass, int *jobnum, int *framenum, int *xres, int *yres, char *outputext);
 
void _web_setrenderpower(int slavekey, char *slavepass, int renderpower);
 
int slaveBenchmark(char *datadir, int *benchmarkTime, int *renderPower);
 

	
0 comments (0 inline, 0 general)