Changeset - 7c98a38ebf04
[Not reviewed]
default
0 1 0
LordOfWar - 16 years ago 2009-10-01 05:03:47

fixed simple error in main()'s user interface where it would exit the user interface when you chose to print all the jobnums in the queue
1 file changed with 3 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/server/distrend.c
Show inline comments
 
@@ -530,132 +530,134 @@ int main(int argc, char *argv[])
 
    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);
 

	
 
  int command;
 
  jobnum_t jobnum;
 
  struct distrenjob *tmp_job;
 
  struct frameset *tmp_frame;
 
  int type;
 
  char *name = "";
 
  char *submitter = "";
 
  char *email = "";
 
  int priority;
 
  int start_frame;
 
  int end_frame;
 

	
 
  while(1)
 
  {
 
    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-->print jobnums in queue");
 
    printf("7-->exit menu");
 

	
 
    scanf("%d", &command);
 

	
 
    if(command == 6)
 
    if(command == 7)
 
      break;
 

	
 
    switch(command)
 
    {
 
    case 1:
 
      printf("job number:");
 
      scanf("%d", &jobnum);
 
      printJob(distrenjob_get(&head, jobnum));
 
      break;
 
    case 2:
 
      printf("job number:");
 
      scanf("%d", &jobnum);
 
      printJobInfo(distrenjob_get(&head, jobnum));
 
      break;
 
    case 3:
 
      find_jobframe(&head, &tmp_job, &tmp_frame);
 
      printf("job#:%d", tmp_job->jobnum);
 
      printf("frame#:%d", tmp_frame->num);
 
      break;
 
    case 4:
 
      printf("type 1:blender, 2:povray"); scanf("%d", &type);
 
      printf("name:");                    scanf("%s", name);
 
      printf("submitter");                scanf("%s", submitter);
 
      printf("e-mail");                   scanf("%s", email);
 
      printf("priority");                 scanf("%d", &priority);
 
      printf("start frame");              scanf("%d", &end_frame);
 
      printf("end frame");                scanf("%d", &start_frame);
 
      prepare_distrenjob(&head, type, name, submitter, email, priority, start_frame, end_frame);
 
      break;
 
    case 5:
 
      printf("job number:");
 
      scanf("%d", &jobnum);
 
      distrenjob_remove(&head, distrenjob_get(&head, jobnum));
 
      break;
 
    case 6:
 
      printAllJobnums(&head);
 
      break;
 
    default:
 
      printf("invalid input");
 
    }
 
  }
 

	
 
  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.
 
      	}
 

	
 
      distrend_action_free(action);
 
    }
 

	
 
  distrend_unlisten(listenset);
 
  distrend_config_free(config);
 

	
 
  return 0;
 
}
0 comments (0 inline, 0 general)