Changeset - 20a058f57a34
[Not reviewed]
default
0 1 0
LordOfWar - 16 years ago 2009-09-30 23:58:13

fixed silly mistakes that I made in previous commit, learned how to use scanf() etc...
1 file changed with 5 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/server/distrend.c
Show inline comments
 
@@ -490,117 +490,118 @@ void printJobInfo(struct distrenjob *hea
 
int main(int argc, char *argv[])
 
{
 

	
 
  /* Argument-parser */
 
  int counter = 0;
 
  int test = 0; // Have some fun if-ness that does fun stuff when this is 1
 
  int die = 0;
 

	
 
  for(counter=0; counter<argc; counter++){
 
         if(strcmp(argv[counter], "-h") == 0) {
 
           fprintf(stderr, "Usage: distrend [option] \nStarts the distrend server\n\t-h\tshow this help\n\t-t\tlaunches queue testing interface \n");
 
           return 2;
 
          }
 

	
 
          else if(strcmp(argv[counter], "-t") == 0) {
 
            fprintf(stderr, "Entering into test mode...\n\n");
 
            test=1;
 
          }
 
          else{
 
            fprintf(stderr, "Please enter some compatible args (see -h), or invoke with no args.\n\n");
 
            die=1;
 
          }
 
  }
 
  if(die==1){
 
    return 3;
 
  }
 

	
 
  struct distrenjob head;
 
  head.priority = 0; // make head have the highest priority
 

	
 
  int cont;
 
  struct distrend_listenset *listenset;
 
  struct distrend_config *config;
 

	
 
  enum clientstatus
 
  {
 
    CLIENTSTATUS_UNINITIALIZED = 0,
 
    CLIENTSTATUS_BUSY = 1,
 
    CLIENTSTATUS_IDLE = 2
 
  } clientstatus;
 

	
 
  cont = 1;
 
  memset(&head, '\0', sizeof(struct distrenjob));
 

	
 
  start_data(); // Starts fresh or loads data from xml dump. Should we grab the return?
 

	
 
  distrend_do_config(argc, argv, &config);
 

	
 
  while(t==1)
 
  while(1)
 
  {
 
	  int command;
 
	  jobnum_t jobnum;
 
	  printf("1-->print all frames in a job");
 
	  printf("2-->examine certain job");
 
	  printf("3-->get a frame to render");
 
	  printf("4-->add a job");
 
	  printf("5-->delete a job");
 
	  printf("6-->exit menu");
 

	
 
	  command = scanf();
 
	  scanf("%d", &command);
 

	
 
	  if(command == 6)
 
		  break;
 

	
 
	  switch(command)
 
	  {
 
	  case 1:
 
		  printf("job number:");
 
		  command = scanf();
 
		  printJob(distrenjob_get(head, command));
 
		  scanf("%d", &jobnum);
 
		  printJob(distrenjob_get(&head, jobnum));
 
		  break;
 
	  case 2:
 

	
 
		  break;
 
	  case 3:
 
		  break;
 
	  case 4:
 
		  break;
 
	  case 5:
 
		  break;
 
	  }
 
  }
 

	
 
  distrend_listen(&listenset, config);
 
  /* This is called the "main loop" */
 
  while(cont)
 
    {
 
      struct distren_action *action;
 
      int clientsays = 0; /*< temporary example variable, will be replaced when we can handle messages */
 

	
 
      distrend_accept(&action);
 
      cont = distrend_do(action);
 

	
 
      /* Make the following code more event-driven */
 
      frame_watchdog(&head);
 

	
 

	
 
      struct frameset *frame;
 
      struct distrenjob *job;
 

	
 
      /* If the client is idle, must be modified for climbing through linked list of clients (client->clientnum) */
 
      if(clientstatus == CLIENTSTATUS_IDLE)
 
	{
 
	  int returnnum = find_jobframe(&head, &job, &frame); // Finds a frame to render
 
	  if(returnnum)
 
	    {
 
	      fprintf(stderr,"No frames are available to render at this time. Idling...\n");
 
	      sleep(10);
 
	    }
 
	  else
 
	    remotio_send_to_client(frame->num, job->jobnum); // Pseudo-sends data to client
 
	}
 
      /* If the client states that they finished the frame */
 
      	if(clientsays == DISTREN_REQUEST_DONEFRAME){
 
      	  clientstatus = CLIENTSTATUS_IDLE; // Sets the client back to idle
 
      	  finish_frame(&head, job, frame->num); // @TODO: Make sure this actually works.
 
      	}
 

	
0 comments (0 inline, 0 general)