Changeset - 84f81c551688
[Not reviewed]
default
0 3 0
ethanzonca - 16 years ago 2009-10-10 17:18:28

Some moving, killed threads var for now
3 files changed with 24 insertions and 27 deletions:
0 comments (0 inline, 0 general)
src/server/slave.c
Show inline comments
 
@@ -79,16 +79,16 @@ if(argc>1 && (strcmp("-c", argv[1]) == 0
 

	
 
/* Option getter: Creates vars to grab stuff from conf, uses the options include to grab this data */
 
char *username;
 
char *datadir;
 
cfg_t * my_cfg;
 
cfg_opt_t myopts[] = {
 
		CFG_SIMPLE_STR("username", &username),
 
		CFG_SIMPLE_STR("datadir", &datadir),
 
		CFG_END()
 
		};
 
    CFG_SIMPLE_STR("username", &username),
 
    CFG_SIMPLE_STR("datadir", &datadir),
 
    CFG_END()
 
  };
 
struct options_common *commonopts;
 

	
 
username = NULL;
 
options_init(argc,argv,&my_cfg, myopts, "slave", &commonopts);
 
/* End option getter */
 

	
 
@@ -127,15 +127,12 @@ char *pathtoTar;     // Full path to the
 
char *urltoOutput;   // Full URL where output is posted
 
char *pathtoJobfile; // Full path to the job's main file
 
char *pathtoXml;     // Full path to the job's xml file
 
char *pathtoOutput;  // Full path to the output (rendered) file
 
char *outputExt;     // Output Extension (e.g., JPG)
 

	
 
int threads = sysconf(_SC_NPROCESSORS_ONLN); // Equals the number of currently online processors
 
// FOR Win32: int threads = sysinfo.dwNumberOfProcessors;
 

	
 
struct distrenjob *myjob; // Structure to hold data gathered from the XML file
 

	
 
/* If the server says that every frame for jobnum is finished */
 
if( 1 == 0)
 
  {
 
    delete_jobdata(jobnum, datadir);
 
@@ -207,29 +204,20 @@ if(gotframe ==1)
 
  outputExt = myjob->output_format; /* @TODO: FIXME! */
 
  _distren_asprintf(&pathtoOutput, "%s/job%d/output/job%d-frame%d.%s", datadir, jobnum, jobnum, framenum, outputExt ); // Prepares the path to the jobfile
 

	
 

	
 
  /** Series of IF's for jobtype based on xml content */
 
  if(1==1){
 
   exec_blender(myjob, pathtoJobfile, pathtoOutput, framenum, threads); // @TODO: This warning should be fixed :D
 
  }
 

	
 
  // 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; // @TODO: When done rendering, set this.
 
   exec_blender(myjob, pathtoJobfile, pathtoOutput, framenum); // @TODO: This warning should be fixed :D
 
  }
 
  // When blender is finished, run this...
 
  if(busy==2){
 
    fprintf(stderr, "Finished frame %d in job %d, uploading...",framenum,jobnum);
 
    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.
 
  }
 
  fprintf(stderr, "Finished frame %d in job %d, uploading...",framenum,jobnum);
 
  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.
 

	
 
}
 

	
 

	
 
  return 0;
 
}
src/server/slavefuncs.c
Show inline comments
 
@@ -408,13 +408,13 @@ return 1; // Success
 

	
 

	
 
/* Executors */
 

	
 

	
 
/** Executor function for Blender operations */
 
void exec_blender(struct distrenjob* distrenjob, char *input, char *output, int frame, int threads)
 
void exec_blender(struct distrenjob* distrenjob, char *input, char *output, int frame)
 
{
 
  int ret;
 
  char *frame_str;
 

	
 
  /* start execio code */
 
  char *command = "blender"; // @TODO: append .exe if win32?
 
@@ -436,18 +436,27 @@ void exec_blender(struct distrenjob* dis
 
  	      }
 
  	      buf[readlen] = '\0';
 
  	      fprintf(stderr, "read \"%s\"\n", buf);
 
  	    }
 
  	execio_close(testrem);
 
  /* end execio code */
 

	
 
  	if(ret == 1){
 
  		fprintf(stderr,"Error starting Blender. Check your install.\n");
 
  	}
 
  	else{
 
  		fprintf(stderr,"Blender at least started nicely, we don't know if it rendered anything though.\n");
 
  	}
 
  	// Consider placing the following in the exec_blender() function
 
  	while(busy){
 
  	  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
 
  	}
 

	
 

	
 
}
 

	
 
void xmlinit()
 
{
 
  xmlInitParser();
 
  xmlXPathInit();
src/server/slavefuncs.h
Show inline comments
 
@@ -33,11 +33,11 @@ size_t curl_writetodisk(void *ptr, size_
 
int curlget(char *url, char *out);
 
int curlpost(char *filename, char *url);
 
int ssh_keygen();
 
int register_user(char *username, char *email);
 
int login_user(char *username);
 
int conf_replace(char *username);
 
void exec_blender(struct distrenjob* distrenjob, char *input, char *output, int frame, int threads);
 
void exec_blender(struct distrenjob* distrenjob, char *input, char *output, int frame);
 
void xmlinit();
 
void xmlcleanup();
 

	
 
#endif
0 comments (0 inline, 0 general)