static int arg_to_qlist(char *arg, char *sep, QueueList **qlist_ptr) { char *id = "arg_to_qlist"; QueueList *qptr = NULL, *new_qlist; int num = 0; char *name, *exechost, canon[PBS_MAXHOSTNAME + 1]; /* * Multiple lines may be used to add queues to the queue list. Find * the tail of the passed-in list (if there is one), and assign the * qptr to the tail element. Later, the new element will be hung off * qptr's next field (or qptr will be set to it.) */ if (*qlist_ptr) { for (qptr = *qlist_ptr; qptr->next != NULL; qptr = qptr->next) /* Walk the list, looking for last element. */; } else { qptr = NULL; } for (name = strtok(arg, sep); name != NULL; name = strtok(NULL, sep)) { /* * If the list is NULL, create the first element and point qptr * at it. If not, take the qptr from the last iteration (which * will be the head the second time through) and place a new * element on its next pointer. Then replace qptr with the * address of the newly allocated struct. */ new_qlist = (QueueList *)malloc(sizeof(QueueList)); if (new_qlist == NULL) { log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, "malloc(newQueue)"); goto error_in_list; } memset(new_qlist, 0, sizeof(QueueList)); if (qptr == NULL) { *qlist_ptr = new_qlist; qptr = *qlist_ptr; } else { qptr->next = new_qlist; qptr = new_qlist; } new_qlist->queue = (Queue *)malloc(sizeof(Queue)); if (new_qlist->queue == NULL) { log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, "malloc(newQueue->queue)"); goto error_in_list; } memset(new_qlist->queue, 0, sizeof(Queue)); /* * Queue names may be either 'queue3' or 'queue3@exechost'. * If there is a '@', convert it to a '\0' and copy the two * halves of the string into the qname and exechost fields. * Otherwise, this queue is local to this host - paste in the * "local" hostname. */ if ((exechost = strchr(name, '@')) != NULL) { /* Parse queue@host into queue and hostname. */ *exechost = '\0'; /* '@' ==> '\0' to terminate qname */ exechost ++; /* Next character after the new '\0' */ if (get_fullhostname(exechost, canon, PBS_MAXHOSTNAME) == 0) { exechost = canon; /* Point at canonical name. */ } else { sprintf(log_buffer, "Warning: Cannot canonicalize queue %s@%s", name, exechost); log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer); DBPRT(("%s: %s\n", id, log_buffer)); } } else { exechost = schd_ThisHost; /* Queue lives on localhost. */ } new_qlist->queue->qname = schd_strdup(name); if (new_qlist->queue->qname == NULL) { log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, "schd_strdup(qname)"); goto error_in_list; } new_qlist->queue->exechost = schd_strdup(exechost); if (new_qlist->queue->exechost == NULL) { log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, "schd_strdup(exechost)"); goto error_in_list; } num++; } return (num); error_in_list: /* Something went wrong - delete the new list and return a fatal error. */ if (*qlist_ptr) { schd_destroy_qlist(*qlist_ptr); *qlist_ptr = NULL; } return (-1); }
static void reset_config(void) { int i; /* char *id = "reset_config"; */ /* * Clear out any contents of the lists previously defined. */ if (schd_SubmitQueue) schd_destroy_qlist(schd_SubmitQueue); if (schd_BatchQueues) schd_destroy_qlist(schd_BatchQueues); if (schd_FairACL) schd_destroy_fairacl(schd_FairACL); /* * Clear queue list head pointers. The contents of the lists have * been destroyed, but the head still points to invalidated memory. */ schd_SubmitQueue = NULL; schd_BatchQueues = NULL; schd_FairACL = NULL; schd_FirstRun = 1; /* First run since reconfig */ /* * Reset scheduler configuration parameters */ schd_ENFORCE_PRIME_TIME = 0; schd_PRIME_TIME_START = 0; schd_PRIME_TIME_END = 0; schd_PT_WALLT_LIMIT = 0; schd_TARGET_LOAD_PCT = 90; schd_TARGET_LOAD_MINUS = 15; schd_TARGET_LOAD_PLUS = 10; schd_MAX_USER_RUN_JOBS = 10; schd_SCHED_RESTART_ACTION = 0; /* * Free allocated storage for configuration commands. */ if (schd_SCHED_HOST) free(schd_SCHED_HOST); if (schd_JOB_DUMPFILE) free(schd_JOB_DUMPFILE); schd_SCHED_HOST = NULL; schd_JOB_DUMPFILE = NULL; /* * Clear file change times. NULL means "clear all files". */ schd_forget_file(NULL); schd_ThisHost[0] = '\0'; /* Get the text-strings for the scheduler commands. */ create_sched_cmdstr(); /* Initialize Qpriorities array */ for (i = 0; i < MAX_PRIORITIES; i++) { QprioritiesArray[i].qname[0] = '\0'; QprioritiesArray[i].priority = -1; } }