Ejemplo n.º 1
0
/**
 * @brief
 *		free_resource_resv - free a resource resv strcture an all of it's ptrs
 *
 * @param[in]	resresv	-	resource_resv to free
 *
 * @return	nothing
 *
 */
void
free_resource_resv(resource_resv *resresv)
{
	if (resresv == NULL)
		return;

	if (resresv->name != NULL)
		free(resresv->name);

	if (resresv->user != NULL)
		free(resresv->user);

	if (resresv->group != NULL)
		free(resresv->group);

	if (resresv->project != NULL)
		free(resresv->project);

	if (resresv->nodepart_name != NULL)
		free(resresv->nodepart_name);

	if (resresv->select != NULL)
		free_selspec(resresv->select);

	if (resresv->execselect != NULL)
		free_selspec(resresv->execselect);

	if (resresv->place_spec != NULL)
		free_place(resresv->place_spec);

	if (resresv->resreq != NULL)
		free_resource_req_list(resresv->resreq);

	if (resresv->ninfo_arr != NULL)
		free(resresv->ninfo_arr);

	if (resresv->nspec_arr != NULL)
		free_nspecs(resresv->nspec_arr);

	if (resresv->job != NULL)
		free_job_info(resresv->job);

	if (resresv->resv != NULL)
		free_resv_info(resresv->resv);

	if (resresv->aoename != NULL)
		free(resresv->aoename);

	if (resresv->eoename != NULL)
		free(resresv->eoename);

	if (resresv->node_set_str != NULL)
		free_string_array(resresv->node_set_str);

	if (resresv->node_set != NULL)
		free(resresv->node_set);

	free(resresv);
}
Ejemplo n.º 2
0
/*
 *
 * free_prev_job_info - free a prev_job_info struct
 *
 *   pjinfo - prev_job_info to free
 *
 * returns nothing
 *
 */
void free_prev_job_info(prev_job_info *pjinfo)
{
    if (pjinfo -> name != NULL)
        free(pjinfo -> name);

    if (pjinfo -> account != NULL)
        free(pjinfo -> account);

    free_resource_req_list(pjinfo -> resused);
}
Ejemplo n.º 3
0
/**
 * @brief
 *		free_chunk - destructor for chunk
 *
 * @param[in,out]	ch	-	chunk structure to be freed.
 */
void
free_chunk(chunk *ch)
{
	if (ch == NULL)
		return;

	if (ch->str_chunk != NULL)
		free(ch->str_chunk);

	if (ch->req != NULL)
		free_resource_req_list(ch->req);

	free(ch);
}
Ejemplo n.º 4
0
/**
 * @brief
 *		update_resresv_on_end - update a resource_resv structure when
 *				      it ends
 *
 * @param[out]	resresv	-	the resresv to update
 * @param[in]	job_state	-	the new state if resresv is a job
 *
 * @return	nothing
 *
 */
void
update_resresv_on_end(resource_resv *resresv, char *job_state)
{
	queue_info *resv_queue;
	resource_resv *next_occr = NULL;
	time_t next_occr_time;
	char logbuf[MAX_LOG_SIZE];
	int ret;
	int i;

	if (resresv == NULL)
		return;

	/* now that it isn't running, it might be runnable again */
	resresv->can_not_run = 0;

	/* unless of course it's a job and its queue is in an ineligible state */
	if (resresv->is_job && resresv->job != NULL &&
		!resresv->job->queue->is_ok_to_run)
		resresv->can_not_run = 1;

	/* no longer running... clear start and end times */
	resresv->start = UNSPECIFIED;
	resresv->end = UNSPECIFIED;

	if (resresv->is_job && resresv->job != NULL) {
		set_job_state(job_state, resresv->job);
		if (resresv->job->is_suspended) {
#ifndef NAS /* localmod 005 */
			int i;
#endif /* localmod 005 */
			nspec **ns = resresv->nspec_arr;
			resresv->job->is_susp_sched = 1;
			for (i = 0; ns[i] != NULL; i++)
				ns[i]->ninfo->num_susp_jobs++;
		}

		resresv->job->is_provisioning = 0;

		/* free resources allocated to job since it's now been requeued */
		if (resresv->job->is_queued && !resresv->job->is_checkpointed) {
			free(resresv->ninfo_arr);
			resresv->ninfo_arr = NULL;
			free_nspecs(resresv->nspec_arr);
			resresv->nspec_arr = NULL;
			free_resource_req_list(resresv->job->resused);
			resresv->job->resused = NULL;
			if (resresv->nodepart_name != NULL) {
				free(resresv->nodepart_name);
				resresv->nodepart_name = NULL;
			}
			free_selspec(resresv->execselect);
			resresv->execselect = NULL;
		}
	}
	else if (resresv->is_resv && resresv->resv !=NULL) {
		resresv->resv->resv_state = RESV_DELETED;

		resv_queue = find_queue_info(resresv->server->queues,
			resresv->resv->queuename);
		if (resv_queue != NULL) {
			resv_queue->is_started = 0;
			ret = is_ok_to_run_queue(resresv->server->policy, resv_queue);
			if (ret == SUCCESS)
				resv_queue->is_ok_to_run = 1;
			else
				resv_queue->is_ok_to_run = 0;

			if (resresv->resv->is_standing) {
				/* This occurrence is over, move resv pointers of all jobs that are
				 * left to next occurrence if one exists
				 */
				if (resresv->resv->resv_idx < resresv->resv->count) {
					next_occr_time = get_occurrence(resresv->resv->rrule,
						resresv->resv->req_start, resresv->resv->timezone, 2);
					if (next_occr_time >= 0) {
						next_occr = find_resource_resv_by_time(resresv->server->resvs,
							resresv->name, next_occr_time);
						if (next_occr != NULL) {
							if (resv_queue->jobs != NULL) {
								for (i = 0; resv_queue->jobs[i] != NULL; i++) {
									if (in_runnable_state(resv_queue->jobs[i]))
										resv_queue->jobs[i]->job->resv = next_occr;
								}
							}
						}
						else {
							snprintf(logbuf, MAX_LOG_SIZE,
								"Can't find occurrence of standing reservation at time %ld",
								next_occr_time);
							schdlog(PBSEVENT_DEBUG, PBS_EVENTCLASS_SERVER, LOG_DEBUG,
								resresv->name, logbuf);
						}
					}
				}
			}
		}
	}
}