Changeset - 4fa20a1a4a19
[Not reviewed]
default
0 1 0
ethanzonca - 16 years ago 2009-07-06 18:26:02

Added some placeholders and other organizational things.
1 file changed with 43 insertions and 52 deletions:
0 comments (0 inline, 0 general)
src/server/distrend.c
Show inline comments
 
@@ -31,57 +31,92 @@
 
#include "execio.h"
 
#include "options.h"
 
#include <confuse.h>
 

	
 
#define max 100 // maximum number of stored jobs in memory, per job type (lux/blend). Eventually we can dump this data to disk, or atleast the remainder not in memory...
 

	
 
// Global Vars, try to cut down on these
 
int jobnum = 0; // The next job number to create in the queue
 
int hcfjob; // Highest consecutively finished job
 
int highest_jobnum; // The job number of the most recently created job, this is used when creating new jobs
 

	
 
/* ******************* Structs ************************ */
 

	
 

	
 
// Stores config info? editmycomment
 
struct distrend_config
 
{
 
  cfg_t *mycfg;
 
  struct options_common *options;
 
  struct distrend_listen **listens; /*< Null terminated array of structs */
 
}
 

	
 

	
 
// Structures for storing job information
 
// Stores Blender Job Info
 
struct {
 
  char *name;
 
  char *submitter;
 
  char *email;
 
  int priority;  // 1 is lowest, 10 is highest, 0 is done
 
  int percent_done;
 
  int completed_frames; // number of completed frames
 
  int assigned_frames; // number of assigned frames (that are not yet completed)
 
  int total_frames; // how many frames are in the animation
 
  struct frameset **frameset;
 

	
 
  // Ok... what's going on with using these??? --ethanzonca
 
  int frame_num[];
 
  char slave_name[][];
 
  short int frame_status[];
 

	
 
} blendjob[max];
 

	
 

	
 

	
 
/*
 
// -- Matthew's handywork --
 
// struct for storing information on each frame for a particular blender job
 
struct {
 
	int frame_num; // frame number to render
 
	char slave_name; // user that frame is assigned to
 
	int frame_status; // status of frame, 0= unassigned, 1= taken, 2= done
 
} frameset[]; // Frameset array is generated by status_report_generator function
 
                         // Using this method to save memory, because if animation starts on a high frame number, it would waste a lot of RAM on empty structures
 
// -- end of Matthew's handywork --
 
*/
 

	
 

	
 

	
 
/* ********************** Functions ************************* */
 

	
 
// **** Finish-Setter: Sets a frame to the "completed" status. Should be modified to set =2 rather than ++ ?
 
void finish_frame(int frame){
 
	blendjob[jobnum].frame_status[frame]++;
 
}
 

	
 

	
 
// **** Queuer: Adds files to the queue
 
void queue(int type, char *name, char *submitter, char *email, int priority, int mode, int spp, *frameset) {
 
	// Type: 1 = blender, add more types later
 
	// jobnum is the next available job number
 
	if(type == 1){
 
    blendjob[jobnum].name = name;
 
    blendjob[jobnum].submitter = submitter;
 
    blendjob[jobnum].email = email;
 
    blendjob[jobnum].priority = priority;
 
    blendjob[jobnum].frameset =  frameset;
 
  }
 
  else{
 
    // Throw error.
 
  }
 
jobnum++; // Advance the jobnumber for the next queued job
 
}
 

	
 

	
 

	
 

	
 

	
 
/* ************************** Main ************************* */
 

	
 
int main(int argc, char *argv[])
 
{
 

	
 
// Begin non-working framework?
 
	int distrend_do_config(int argc, char *argv[], struct distrend_config *config)
 
	{
 
@@ -139,13 +174,13 @@ int main(int argc, char *argv[])
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 
/* ************************ Aaaaaah ************************ */
 

	
 

	
 

	
 

	
 
/*
 
 frame[frame] Assignments:
 
@@ -376,65 +411,27 @@ void status_report_generator(){
 

	
 
			num1++;
 
		}
 

	
 
	}
 

	
 
// This function makes the value of the frame 2, which means its completed.
 
void the_finisher(int frame){
 
	blendjob[jobnum].frame_status[frame]++;
 
}
 

	
 
// Queuer: this function should add files to the queue
 
// Type: 0 = blender, 1 = luxrender
 
// jobnum is the current job number
 

	
 
void queue(int type, char *name, char *submitter, char *email, int priority, int mode, int spp, *frameset) {
 
  if(type == 1){
 
    blendjob[jobnum].name = name;
 
    blendjob[jobnum].submitter = submitter;
 
    blendjob[jobnum].email = email;
 
    blendjob[jobnum].priority = priority;
 
    blendjob[jobnum].frameset =  frameset;
 
  }
 
  if(type == 2){
 
    luxjob[jobnum].name = name;
 
    luxjob[jobnum].submitter = submitter;
 
    luxjob[jobnum].email = email;
 
    luxjob[jobnum].priority = priority;
 
    luxjob[jobnum].mode = mode;
 
    luxjob[jobnum].spp = spp;
 
    luxjob[jobnum].frameset = frameset;
 
    // handle lux modes somehow.
 
}
 
  else{
 
    // Throw error.
 
  }
 
jobnum++;
 
}
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 
/*
 
 * --------------------------------------------------------------------
 
 * Slave code resides below.
 
 * **********************************************************************************
 
 * Slave functions / etc resides below. Wouldn't a seperate file make this easier??
 
 *
 
 * Slave listens on server for a command in the format of each function...
 
 * We need if's for returns... ==> watchdog
 
 * **********************************************************************************
 
*/
 

	
 

	
 

	
 

	
 
// Registration on server. Needs attention. Prevent account spamming.
 
// Key transfer?
 
// Set up something like: distrend -c username email@example.com
 
void registeruser(char *username, char *email){
 
  // Logs into sandboxed user on zserver2 and registers a user. Should eventually generate a key on the server and return it to the user.
 
  // All created user accounts should be sandboxed accordingly, requiring a different skel, and the default shell to be rbash. Also,
 
@@ -475,15 +472,12 @@ void registeruser(char *username, char *
 
    fprintf(stderr, "read \"%s\"\n", buf);
 
    }
 
  execio_close(testrem);
 
}
 

	
 

	
 

	
 

	
 

	
 
void loginuser(char *username, int secret){
 
  // Logs into sandboxed user on zserver2 as a client, currently does nothing
 
  char buf[10];
 
  struct execio *testrem;
 
  char *execargv[] =
 
    {
 
@@ -512,15 +506,12 @@ void loginuser(char *username, int secre
 
    fprintf(stderr, "read \"%s\"\n", buf);
 
    }
 
  execio_close(testrem);
 
}
 

	
 

	
 

	
 

	
 

	
 
// Executors
 

	
 
void exec_blender(char *input, char *output, int frame) {
 
  int ret;
 
  /* SEGFAULTAGE :-D */
 
  char *cmd[] = { "blender", "-b", "-o", output, input, "-f", frame, (char *)0 };
0 comments (0 inline, 0 general)