Changeset - 7f610e2808f2
[Not reviewed]
default
0 3 0
Ethan Zonca (ethanzonca) - 15 years ago 2010-03-23 00:23:20
e@ethanzonca.com
Fixed many memory leaks
3 files changed with 25 insertions and 8 deletions:
0 comments (0 inline, 0 general)
src/common/options.c
Show inline comments
 
@@ -102,12 +102,14 @@ int options_init(int argc, char *argv[],
 
  workingdir = distren_getcwd();
 
  if(!workingdir)
 
    fprintf(stderr, "Error finding working directory, I will not be able to return to it after reading the configuration files\n");
 
  if(chdir(configfileprefix))
 
    fprintf(stderr, "Unable to chdir(\"%s\") where I expected to find config files, expect failure\n", configfileprefix);
 

	
 
  free(configfileprefix);
 

	
 
  _distren_asprintf(&configfile, "%s%s.conf", PACKAGE, myname);
 
  if(!configfile)
 
    {
 
      perror("blah");
 
      free(workingdir);
 
      return 1;
src/server/simpleslave.c
Show inline comments
 
@@ -208,12 +208,13 @@ int main(int argc, char *argv[])
 
          {
 
            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
 
            return 1;
 
          }
 
        free(pathtoJobfile);
 
        pathtoJobfile = NULL;
 

	
 
        struct stat buffer;
 
        int fstatus = stat(pathtoOutput, &buffer);
 
        if(fstatus == -1){
 
          fprintf(stderr,"*** %s doesn't exist! Scene may not have camera, or your blender installation is not working.\n", pathtoOutput);
 
          _web_resetframe(slavekey, password, jobnum, framenum);  // Unassign the frame on the server so other slaves can render it
 
@@ -223,13 +224,14 @@ int main(int argc, char *argv[])
 
          /* Post-execution */
 
          fprintf(stderr, "Finished frame %d in job %d, uploading...\n", framenum, jobnum);
 
          uploadOutput(pathtoOutput, urltoOutput, jobnum, framenum, slavekey); // @TODO: Handle return value
 

	
 
          free(urltoOutput);
 
          free(pathtoOutput);
 

	
 
          urltoOutput = NULL;
 
          pathtoOutput = NULL;
 
          // Tell the server that rendering and upload are complete
 
          _web_finishframe(slavekey, password, jobnum, framenum);
 
        }
 
      }
 
    else{
 
      fprintf(stderr,"Nothing to do. Idling...\n");
 
@@ -242,9 +244,21 @@ int main(int argc, char *argv[])
 
        // Note: individual frames are already deleted after uploading,
 
        // except for ones that couldn't be uploaded
 
        delete_jobdata(jobnum, datadir);
 
      }
 
  }
 

	
 
  free(my_cfg);
 
  free(outputExt);
 
  free(datadir);
 
  free(urltoTar);
 
  free(pathtoTar);
 
  free(pathtoTardir);
 
  free(pathtoJob);
 
  free(pathtoJobfile);
 
  free(urltoJobfile);
 
  free(urltoOutput);
 
  free(pathtoRenderOutput);
 
  free(pathtoOutdir);
 
  fprintf(stderr,"Goodbye!\n");
 
  return 0;
 
}
src/server/slavefuncs.c
Show inline comments
 
@@ -235,12 +235,15 @@ int curlpost(char *filename, char *url, 
 
    res = curl_easy_perform(curl);
 

	
 
    curl_easy_cleanup(curl);
 
    /* cleanup the formpost junk */
 
    curl_formfree(formpost);
 
    curl_slist_free_all (headerlist);
 
    free(sjobnum);
 
    free(sframenum);
 
    free(sslavekey);
 
  }
 
  return res;
 
}
 

	
 

	
 
/** Logs the user into the server after ensuring that keys exist */
 
@@ -320,13 +323,13 @@ int exec_blender(char *input, char *outp
 
        fprintf(stderr, "Something is terribly wrong!\n");
 
       }
 
       buf[readlen] = '\0';
 
       fprintf(stderr, "read \"%s\"\n", buf);
 
    }
 
  execio_close(testrem);
 

	
 
  free(frame_str);
 
  return ret;
 
}
 

	
 
void xmlinit()
 
{
 
  xmlInitParser();
 
@@ -675,15 +678,13 @@ struct _web_memorystruct _web_getrequest
 
    res = curl_easy_perform(curl);
 
    curl_easy_cleanup(curl);
 
  }
 

	
 
  /* we're done with libcurl, so clean it up */
 
  curl_global_cleanup();
 

	
 
  return chunk; // 0 is OK, 1 is 404 or other error
 

	
 
}
 

	
 
void _web_finishframe(int slavekey, char *slavepass, int jobnum, int framenum){
 
  char *url;
 
  _distren_asprintf(&url,"http://dev.distren.org/slave/act.php?mode=finishframe&slavekey=%d&slavepass=%s&jobnum=%d&framenum=%d", slavekey, slavepass, jobnum, framenum);
 
  struct _web_memorystruct data = _web_getrequest(url);
 
@@ -826,16 +827,16 @@ int slaveBenchmark(char *datadir, int *b
 
  if(ostatus == -1){
 
    ret = 1; // Return error if output wasn't generated
 
  }
 
  else
 
    remove(output);
 

	
 
  free(frame_str);
 
  free(input);
 
  free(output);
 

	
 
  *benchmarkTime = abs(difftime(startTime,endTime));
 
  float tmp = *benchmarkTime;
 
  tmp = (1/tmp) * 50000;
 
  *renderPower = (int)tmp;
 
  free(realOutput);
 
  free(frame_str);
 
  free(input);
 
  free(output);
 
  return ret;
 
}
0 comments (0 inline, 0 general)