Ejemplo n.º 1
0
/*
 * _delete_config_record - delete all configuration records
 * RET 0 if no error, errno otherwise
 * global: config_list - list of all configuration records
 */
static int _delete_config_record (void)
{
	last_node_update = time (NULL);
	(void) list_delete_all(config_list,    &_list_find_config,  NULL);
	(void) list_delete_all(front_end_list, &list_find_frontend, NULL);
	return SLURM_SUCCESS;
}
Ejemplo n.º 2
0
Archivo: opt.c Proyecto: kainz/diod
int
opt_addf (Opt o, const char *fmt, ...)
{
    va_list ap;
    char *csv, *item, *cpy;
    char *saveptr = NULL;
    int error;

    NP_ASSERT (o->magic == OPT_MAGIC);
    va_start (ap, fmt);
    error = vasprintf (&csv, fmt, ap);
    va_end (ap);
    if (error < 0)
        msg_exit ("out of memory");

    item = strtok_r (csv, ",", &saveptr);
    while (item) {
        if (!(cpy = strdup (item)))
            msg_exit ("out of memory");
        (void)list_delete_all (o->list, (ListFindF)_match_key, cpy);   
        if (!list_append (o->list, cpy))
            msg_exit ("out of memory");
        item = strtok_r (NULL, ",", &saveptr);
    }
    free (csv);
    return 1;
}
Ejemplo n.º 3
0
Archivo: opt.c Proyecto: kainz/diod
/* Returns number of deletions.
 */
int
opt_delete (Opt o, char *key)
{
    NP_ASSERT (o->magic == OPT_MAGIC);

    return list_delete_all (o->list, (ListFindF)_match_key, key);   
}
Ejemplo n.º 4
0
int 
cerebro_event_unregister(cerebro_t handle, int fd)
{
  if (_cerebro_handle_check(handle) < 0)
    return -1;

  if (fd < 0)
    {
      handle->errnum = CEREBRO_ERR_PARAMETERS;
      return -1;
    }

  if (!list_find_first(handle->event_fds, _event_fd_find, &fd))
    {
      handle->errnum = CEREBRO_ERR_PARAMETERS;
      return -1;
    }

  if (!list_delete_all(handle->event_fds, _event_fd_find, &fd))
    {
      handle->errnum = CEREBRO_ERR_INTERNAL;
      return -1;
    }

  /* ignore potential error, just return result */
  close(fd);

  handle->errnum = CEREBRO_ERR_SUCCESS;
  return 0;
}
Ejemplo n.º 5
0
STATUS list_free(LIST_HEAD *p_head)
{
     list_delete_all(p_head);
     free(p_head);

     return ST_SUCCESS;
}
Ejemplo n.º 6
0
static int _alljobids_requested (List l)
{
    char *all = "all";
    if (l == NULL)
        return (0);
    return (list_delete_all (l, (ListFindF)_find_str, all));
}
Ejemplo n.º 7
0
Archivo: sicp.c Proyecto: rohgarg/slurm
extern void *_sicp_agent(void *args)
{
    static time_t last_sicp_time = 0;
    time_t now;
    double wait_time;

    while (!sicp_stop) {
        _my_sleep(1);
        if (sicp_stop)
            break;

        now = time(NULL);
        wait_time = difftime(now, last_sicp_time);
        if (wait_time < sicp_interval)
            continue;
        last_sicp_time = now;

        _load_sicp_other_cluster();

        pthread_mutex_lock(&sicp_lock);
        list_delete_all(sicp_job_list, &_list_find_sicp_old, "");
        if (slurm_get_debug_flags() & DEBUG_FLAG_SICP)
            _log_sicp_recs();
        pthread_mutex_unlock(&sicp_lock);

        _dump_sicp_state();	/* Has own locking */
    }
    return NULL;
}
Ejemplo n.º 8
0
/*
 * _delete_part_record - delete record for partition with specified name
 * IN name - name of the desired node, delete all partitions if NULL
 * RET 0 on success, errno otherwise
 * global: part_list - global partition list
 */
static int _delete_part_record(char *name)
{
	int i;

	last_part_update = time(NULL);
	if (name == NULL) {
		i = list_delete_all(part_list, &list_find_part,
				    "universal_key");
	} else
		i = list_delete_all(part_list, &list_find_part, name);
	if ((name == NULL) || (i != 0))
		return 0;

	error("_delete_part_record: attempt to delete non-existent "
	      "partition %s", name);
	return ENOENT;
}
Ejemplo n.º 9
0
static void *
_pstdout_func_entry(void *arg)
{
    struct pstdout_thread_data *tdata = NULL;
    struct pstdout_state pstate;
    int rc;

    tdata = (struct pstdout_thread_data *)arg;

    if (_pstdout_state_init(&pstate, tdata->hostname) < 0)
        goto cleanup;

    if ((rc = pthread_mutex_lock(&pstdout_states_mutex)))
    {
        if (pstdout_debug_flags & PSTDOUT_DEBUG_STANDARD)
            fprintf(stderr, "pthread_mutex_lock: %s\n", strerror(rc));
        pstdout_errnum = PSTDOUT_ERR_INTERNAL;
        goto cleanup;
    }

    if (!list_append(pstdout_states, &pstate))
    {
        if (pstdout_debug_flags & PSTDOUT_DEBUG_STANDARD)
            fprintf(stderr, "list_append: %s\n", strerror(errno));
        pstdout_errnum = PSTDOUT_ERR_INTERNAL;
        pthread_mutex_unlock(&pstdout_states_mutex);
        goto cleanup;
    }

    if ((rc = pthread_mutex_unlock(&pstdout_states_mutex)))
    {
        if (pstdout_debug_flags & PSTDOUT_DEBUG_STANDARD)
            fprintf(stderr, "pthread_mutex_lock: %s\n", strerror(rc));
        pstdout_errnum = PSTDOUT_ERR_INTERNAL;
        goto cleanup;
    }

    tdata->exit_code = (tdata->pstdout_func)(&pstate, tdata->hostname, tdata->arg);

    if (_pstdout_output_finish(&pstate) < 0)
        goto cleanup;

cleanup:
    pthread_mutex_lock(&pstdout_states_mutex);
    list_delete_all(pstdout_states, _pstdout_states_delete_pointer, &pstate);
    pthread_mutex_unlock(&pstdout_states_mutex);
    _pstdout_state_cleanup(&pstate);
    pthread_mutex_lock(&pstdout_threadcount_mutex);
    pstdout_threadcount--;
    pthread_cond_signal(&pstdout_threadcount_cond);
    pthread_mutex_unlock(&pstdout_threadcount_mutex);
    return NULL;
}
Ejemplo n.º 10
0
optparse_err_t optparse_remove_option (optparse_t p, const char *name)
{
    optparse_err_t rc = OPTPARSE_SUCCESS;

    int n = list_delete_all (p->option_list,
                (ListFindF) option_info_cmp_name,
                (void *) name);

    if (n != 1)
        rc = OPTPARSE_FAILURE;

    return (rc);
}
Ejemplo n.º 11
0
/* Clear active_feature_list,
 * then copy avail_feature_list into active_feature_list */
static void _copy_feature_list(void)
{
	node_feature_t *active_feature_ptr, *avail_feature_ptr;
	ListIterator feature_iter;

	(void) list_delete_all(active_feature_list, &_list_find_feature, NULL);

	feature_iter = list_iterator_create(avail_feature_list);
	while ((avail_feature_ptr = (node_feature_t *)list_next(feature_iter))){
		active_feature_ptr = xmalloc(sizeof(node_feature_t));
		active_feature_ptr->magic = FEATURE_MAGIC;
		active_feature_ptr->name = xstrdup(avail_feature_ptr->name);
		active_feature_ptr->node_bitmap =
			bit_copy(avail_feature_ptr->node_bitmap);
		list_append(active_feature_list, active_feature_ptr);
	}
	list_iterator_destroy(feature_iter);
}
Ejemplo n.º 12
0
/*
 * delete_partition - delete the specified partition (actually leave
 *	the entry, just flag it as defunct)
 * IN job_specs - job specification from RPC
 */
extern int delete_partition(delete_part_msg_t *part_desc_ptr)
{
	struct part_record *part_ptr;

	part_ptr = find_part_record (part_desc_ptr->name);
	if (part_ptr == NULL)	/* No such partition */
		return ESLURM_INVALID_PARTITION_NAME;

	if (partition_in_use(part_desc_ptr->name))
		return ESLURM_PARTITION_IN_USE;

	if (default_part_loc == part_ptr) {
		error("Deleting default partition %s", part_ptr->name);
		default_part_loc = NULL;
	}
	(void) kill_job_by_part_name(part_desc_ptr->name);
	list_delete_all(part_list, list_find_part, part_desc_ptr->name);
	last_part_update = time(NULL);

	slurm_sched_partition_change();	/* notify sched plugin */
	select_g_reconfigure();		/* notify select plugin too */

	return SLURM_SUCCESS;
}
Ejemplo n.º 13
0
/*
 * Return non-zero if jobid is in list of ids requested by user
 */
static int _jobid_requested (List l, uint32_t jobid)
{
    if (l == NULL)
        return (0);
    return (list_delete_all (l, (ListFindF)_find_id, &jobid));
}
Ejemplo n.º 14
0
extern void get_bg_part(void)
{
	int error_code, i, j, recs=0, count = 0, last_count = -1;
	static partition_info_msg_t *part_info_ptr = NULL;
	static partition_info_msg_t *new_part_ptr = NULL;
	static block_info_msg_t *bg_info_ptr = NULL;
	static block_info_msg_t *new_bg_ptr = NULL;
	uint16_t show_flags = 0;
	partition_info_t part;
	db2_block_info_t *block_ptr = NULL;
	db2_block_info_t *found_block = NULL;
	ListIterator itr;
	List nodelist = NULL;
	bitstr_t *nodes_req = NULL;

	if (!(params.cluster_flags & CLUSTER_FLAG_BG))
		return;

	if (params.all_flag)
		show_flags |= SHOW_ALL;
	if (part_info_ptr) {
		error_code = slurm_load_partitions(part_info_ptr->last_update,
						   &new_part_ptr, show_flags);
		if (error_code == SLURM_SUCCESS)
			slurm_free_partition_info_msg(part_info_ptr);
		else if (slurm_get_errno() == SLURM_NO_CHANGE_IN_DATA) {
			error_code = SLURM_SUCCESS;
			new_part_ptr = part_info_ptr;
		}
	} else {
		error_code = slurm_load_partitions((time_t) NULL,
						   &new_part_ptr, show_flags);
	}

	if (error_code) {
		if (quiet_flag != 1) {
			if (!params.commandline) {
				mvwprintw(text_win,
					  main_ycord, 1,
					  "slurm_load_partitions: %s",
					  slurm_strerror(slurm_get_errno()));
				main_ycord++;
			} else {
				printf("slurm_load_partitions: %s\n",
				       slurm_strerror(slurm_get_errno()));
			}
		}
		return;
	}
	if (bg_info_ptr) {
		error_code = slurm_load_block_info(bg_info_ptr->last_update,
						   &new_bg_ptr, show_flags);
		if (error_code == SLURM_SUCCESS)
			slurm_free_block_info_msg(bg_info_ptr);
		else if (slurm_get_errno() == SLURM_NO_CHANGE_IN_DATA) {
			error_code = SLURM_SUCCESS;
			new_bg_ptr = bg_info_ptr;
		}
	} else {
		error_code = slurm_load_block_info((time_t) NULL,
						   &new_bg_ptr, show_flags);
	}
	if (error_code) {
		if (quiet_flag != 1) {
			if (!params.commandline) {
				mvwprintw(text_win,
					  main_ycord, 1,
					  "slurm_load_block: %s",
					  slurm_strerror(slurm_get_errno()));
				main_ycord++;
			} else {
				printf("slurm_load_block: %s\n",
				       slurm_strerror(slurm_get_errno()));
			}
		}
		return;
	}
	if (block_list) {
		/* clear the old list */
		list_delete_all(block_list, _list_match_all, NULL);
	} else {
		block_list = list_create(_block_list_del);
		if (!block_list) {
			fprintf(stderr, "malloc error\n");
			return;
		}
	}
	if (!params.commandline)
		if ((new_bg_ptr->record_count - text_line_cnt)
		   < (text_win->_maxy-3))
			text_line_cnt--;
	if (params.hl)
		nodes_req = get_requested_node_bitmap();
	for (i = 0; i < new_bg_ptr->record_count; i++) {
		if (nodes_req) {
			int overlap = 0;
			bitstr_t *loc_bitmap = bit_alloc(bit_size(nodes_req));
			inx2bitstr(loc_bitmap,
				   new_bg_ptr->block_array[i].mp_inx);
			overlap = bit_overlap(loc_bitmap, nodes_req);
			FREE_NULL_BITMAP(loc_bitmap);
			if (!overlap)
				continue;
		}
		if (params.io_bit && new_bg_ptr->block_array[i].ionode_str) {
			int overlap = 0;
			bitstr_t *loc_bitmap =
				bit_alloc(bit_size(params.io_bit));
			inx2bitstr(loc_bitmap,
				   new_bg_ptr->block_array[i].ionode_inx);
			overlap = bit_overlap(loc_bitmap, params.io_bit);
			FREE_NULL_BITMAP(loc_bitmap);
			if (!overlap)
				continue;
		}

		block_ptr = xmalloc(sizeof(db2_block_info_t));

		block_ptr->bg_block_name
			= xstrdup(new_bg_ptr->block_array[i].bg_block_id);
		block_ptr->mp_str = xstrdup(new_bg_ptr->block_array[i].mp_str);
		block_ptr->nodelist = list_create(_nodelist_del);
		_make_nodelist(block_ptr->mp_str, block_ptr->nodelist);

		block_ptr->bg_user_name
			= xstrdup(new_bg_ptr->block_array[i].owner_name);
		block_ptr->state = new_bg_ptr->block_array[i].state;

		memcpy(block_ptr->bg_conn_type,
		       new_bg_ptr->block_array[i].conn_type,
		       sizeof(block_ptr->bg_conn_type));

		if (params.cluster_flags & CLUSTER_FLAG_BGL)
			block_ptr->bg_node_use =
				new_bg_ptr->block_array[i].node_use;

		block_ptr->ionode_str
			= xstrdup(new_bg_ptr->block_array[i].ionode_str);
		block_ptr->cnode_cnt = new_bg_ptr->block_array[i].cnode_cnt;

		itr = list_iterator_create(block_list);
		while ((found_block = (db2_block_info_t*)list_next(itr))) {
			if (!strcmp(block_ptr->mp_str, found_block->mp_str)) {
				block_ptr->letter_num =
					found_block->letter_num;
				break;
			}
		}
		list_iterator_destroy(itr);

		if (!found_block) {
			last_count++;
			_marknodes(block_ptr, last_count);
		}
		block_ptr->job_running =
			new_bg_ptr->block_array[i].job_running;
		if (block_ptr->bg_conn_type[0] >= SELECT_SMALL)
			block_ptr->size = 0;

		list_append(block_list, block_ptr);
	}

	if (!params.no_header)
		_print_header_part();

	if (new_part_ptr)
		recs = new_part_ptr->record_count;
	else
		recs = 0;

	for (i = 0; i < recs; i++) {
		j = 0;
		part = new_part_ptr->partition_array[i];

		if (!part.nodes || (part.nodes[0] == '\0'))
			continue;	/* empty partition */
		nodelist = list_create(_nodelist_del);
		_make_nodelist(part.nodes, nodelist);

		if (block_list) {
			itr = list_iterator_create(block_list);
			while ((block_ptr = (db2_block_info_t*)
				list_next(itr)) != NULL) {
				if (_in_slurm_partition(nodelist,
						       block_ptr->nodelist)) {
					block_ptr->slurm_part_name
						= xstrdup(part.name);
				}
			}
			list_iterator_destroy(itr);
		}
		list_destroy(nodelist);
	}

	/* Report the BG Blocks */
	if (block_list) {
		itr = list_iterator_create(block_list);
		while ((block_ptr = (db2_block_info_t*)
			list_next(itr)) != NULL) {
			if (params.commandline)
				block_ptr->printed = 1;
			else {
				if (count>=text_line_cnt)
					block_ptr->printed = 1;
			}
			_print_rest(block_ptr);
			count++;
		}
		list_iterator_destroy(itr);
	}


	if (params.commandline && params.iterate)
		printf("\n");

	part_info_ptr = new_part_ptr;
	bg_info_ptr = new_bg_ptr;
	return;
}
Ejemplo n.º 15
0
void list_free(list *listo)
{
	list_delete_all(listo);
	free(listo->names);
	free(listo->items);
}
Ejemplo n.º 16
0
static void rdl_resource_delete (struct rdl *rdl, struct resource *r)
{
    if (!rdl->resource_list)
        return;
    list_delete_all (rdl->resource_list, (ListFindF) ptrcmp, r);
}
Ejemplo n.º 17
0
static void rdllib_rdl_delete (struct rdllib *l, struct rdl *rdl)
{
    if (l->rdl_list)
        list_delete_all (l->rdl_list, (ListFindF) ptrcmp, rdl);
}
Ejemplo n.º 18
0
int
pstdout_launch(const char *hostnames, Pstdout_Thread pstdout_func, void *arg)
{
    struct pstdout_thread_data **tdata = NULL;
    struct pstdout_state pstate;
    unsigned int pstate_init = 0;
    hostlist_iterator_t hitr = NULL;
    hostlist_t h = NULL;
    int h_count = 0;
    char *host = NULL;
    int exit_code = -1;
    sighandler_t sighandler_save = NULL;
    int sighandler_set = 0;
    int rc;
    int i;

    if (!pstdout_initialized)
    {
        pstdout_errnum = PSTDOUT_ERR_UNINITIALIZED;
        return -1;
    }

    if (!pstdout_func)
    {
        pstdout_errnum = PSTDOUT_ERR_PARAMETERS;
        return -1;
    }

    if ((rc = pthread_mutex_lock(&pstdout_launch_mutex)))
    {
        if (pstdout_debug_flags & PSTDOUT_DEBUG_STANDARD)
            fprintf(stderr, "pthread_mutex_lock: %s\n", strerror(rc));
        pstdout_errnum = PSTDOUT_ERR_INTERNAL;
        goto cleanup;
    }

    /* Special case */
    if (!hostnames)
    {
        if (_pstdout_state_init(&pstate, NULL) < 0)
            goto cleanup;
        pstate_init++;

        exit_code = pstdout_func(&pstate, NULL, arg);
        pstdout_errnum = PSTDOUT_ERR_SUCCESS;
        goto cleanup;
    }

    if (!(h = hostlist_create(hostnames)))
    {
        pstdout_errnum = PSTDOUT_ERR_OUTMEM;
        goto cleanup;
    }
    h_count = hostlist_count(h);

    /* Sanity check */
    if (h_count <= 0)
    {
        if (pstdout_debug_flags & PSTDOUT_DEBUG_STANDARD)
            fprintf(stderr, "h_count = %d\n", h_count);
        pstdout_errnum = PSTDOUT_ERR_INTERNAL;
        goto cleanup;
    }

    /* Special case */
    if (h_count == 1)
    {
        if (_pstdout_state_init(&pstate, hostnames) < 0)
            goto cleanup;
        pstate_init++;

        exit_code = pstdout_func(&pstate, hostnames, arg);
        pstdout_errnum = PSTDOUT_ERR_SUCCESS;
        goto cleanup;
    }

    if ((sighandler_save = signal(SIGINT, _pstdout_sigint)) == SIG_ERR)
    {
        if (pstdout_debug_flags & PSTDOUT_DEBUG_STANDARD)
            fprintf(stderr, "signal\n");
        pstdout_errnum = PSTDOUT_ERR_INTERNAL;
        goto cleanup;
    }
    sighandler_set++;

    if (!(hitr = hostlist_iterator_create(h)))
    {
        pstdout_errnum = PSTDOUT_ERR_OUTMEM;
        goto cleanup;
    }

    if (!(tdata = (struct pstdout_thread_data **)malloc(sizeof(struct pstdout_thread_data *) * h_count)))
    {
        pstdout_errnum = PSTDOUT_ERR_OUTMEM;
        goto cleanup;
    }
    memset(tdata, '\0', sizeof(struct pstdout_thread_data *) * h_count);

    i = 0;
    while ((host = hostlist_next(hitr)))
    {
        if (!(tdata[i] = (struct pstdout_thread_data *)malloc(sizeof(struct pstdout_thread_data))))
        {
            pstdout_errnum = PSTDOUT_ERR_OUTMEM;
            goto cleanup;
        }
        memset(tdata[i], '\0', sizeof(struct pstdout_thread_data));

        if (!(tdata[i]->hostname = strdup(host)))
        {
            pstdout_errnum = PSTDOUT_ERR_OUTMEM;
            goto cleanup;
        }
        tdata[i]->pstdout_func = pstdout_func;
        tdata[i]->arg = arg;

        if ((rc = pthread_attr_init(&(tdata[i]->attr))))
        {
            if (pstdout_debug_flags & PSTDOUT_DEBUG_STANDARD)
                fprintf(stderr, "pthread_attr_init: %s\n", strerror(rc));
            pstdout_errnum = PSTDOUT_ERR_INTERNAL;
            goto cleanup;
        }

        if ((rc = pthread_attr_setdetachstate(&(tdata[i]->attr), PTHREAD_CREATE_DETACHED)))
        {
            if (pstdout_debug_flags & PSTDOUT_DEBUG_STANDARD)
                fprintf(stderr, "pthread_attr_setdetachstate: %s\n", strerror(rc));
            pstdout_errnum = PSTDOUT_ERR_INTERNAL;
            goto cleanup;
        }

        free(host);
        i++;
    }
    host = NULL;

    hostlist_iterator_destroy(hitr);
    hitr = NULL;

    hostlist_destroy(h);
    h = NULL;

    /* Launch threads up to fanout */
    for (i = 0; i < h_count; i++)
    {
        if ((rc = pthread_mutex_lock(&pstdout_threadcount_mutex)))
        {
            if (pstdout_debug_flags & PSTDOUT_DEBUG_STANDARD)
                fprintf(stderr, "pthread_mutex_lock: %s\n", strerror(rc));
            pstdout_errnum = PSTDOUT_ERR_INTERNAL;
            goto cleanup;
        }

        if (pstdout_threadcount == pstdout_fanout)
        {
            if ((rc = pthread_cond_wait(&pstdout_threadcount_cond, &pstdout_threadcount_mutex)))
            {
                if (pstdout_debug_flags & PSTDOUT_DEBUG_STANDARD)
                    fprintf(stderr, "pthread_cond_wait: %s\n", strerror(rc));
                pstdout_errnum = PSTDOUT_ERR_INTERNAL;
                goto cleanup;
            }
        }

        if ((rc = pthread_create(&(tdata[i]->tid),
                                 &(tdata[i]->attr),
                                 _pstdout_func_entry,
                                 (void *) tdata[i])))
        {
            if (pstdout_debug_flags & PSTDOUT_DEBUG_STANDARD)
                fprintf(stderr, "pthread_create: %s\n", strerror(rc));
            pstdout_errnum = PSTDOUT_ERR_INTERNAL;
            goto cleanup;
        }

        pstdout_threadcount++;

        if ((rc = pthread_mutex_unlock(&pstdout_threadcount_mutex)))
        {
            if (pstdout_debug_flags & PSTDOUT_DEBUG_STANDARD)
                fprintf(stderr, "pthread_mutex_unlock: %s\n", strerror(rc));
            pstdout_errnum = PSTDOUT_ERR_INTERNAL;
            goto cleanup;
        }
    }

    /* Wait for Threads to finish */

    if ((rc = pthread_mutex_lock(&pstdout_threadcount_mutex)))
    {
        if (pstdout_debug_flags & PSTDOUT_DEBUG_STANDARD)
            fprintf(stderr, "pthread_mutex_lock: %s\n", strerror(rc));
        pstdout_errnum = PSTDOUT_ERR_INTERNAL;
        goto cleanup;
    }

    while (pstdout_threadcount > 0)
    {
        if ((rc = pthread_cond_wait(&pstdout_threadcount_cond, &pstdout_threadcount_mutex)))
        {
            if (pstdout_debug_flags & PSTDOUT_DEBUG_STANDARD)
                fprintf(stderr, "pthread_cond_wait: %s\n", strerror(rc));
            pstdout_errnum = PSTDOUT_ERR_INTERNAL;
            goto cleanup;
        }
    }

    if (_pstdout_output_consolidated_finish() < 0)
        goto cleanup;

    /* Determine exit code */
    exit_code = 0;
    for (i = 0; i < h_count; i++)
    {
        if (tdata[i]->exit_code > exit_code)
            exit_code = tdata[i]->exit_code;
    }

cleanup:
    /* Cannot pass NULL for key, so just pass dummy key */
    list_delete_all(pstdout_consolidated_stdout, _pstdout_consolidated_data_delete_all, "");
    list_delete_all(pstdout_consolidated_stderr, _pstdout_consolidated_data_delete_all, "");
    if (pstate_init)
        _pstdout_state_cleanup(&pstate);
    if (tdata)
    {
        for (i = 0; i < h_count; i++)
        {
            if (tdata[i])
            {
                free(tdata[i]->hostname);
                pthread_attr_destroy(&(tdata[i]->attr));
                free(tdata[i]);
            }
        }
        free(tdata);
    }
    if (hitr)
        hostlist_iterator_destroy(hitr);
    if (h)
        hostlist_destroy(h);
    free(host);
    if ((rc = pthread_mutex_unlock(&pstdout_launch_mutex)))
    {
        if (pstdout_debug_flags & PSTDOUT_DEBUG_STANDARD)
            fprintf(stderr, "pthread_mutex_unlock: %s\n", strerror(rc));
        /* Don't change error code, just move on */
    }
    if (sighandler_set)
        signal(SIGINT, sighandler_save);
    return exit_code;
}
Ejemplo n.º 19
0
void WorkQueue::CancelScheduledWork(WorkableInterface *wi)
{
    pthread_mutex_lock(&wlock);
    works = list_delete_all(works, wi);
    pthread_mutex_unlock(&wlock);
}
Ejemplo n.º 20
0
int
genders_load_data(genders_t handle, const char *filename) 
{
  char *temp;

  if (_genders_unloaded_handle_error_check(handle) < 0)
    goto cleanup;
  
  handle->node_index_size = GENDERS_NODE_INDEX_INIT_SIZE;
  
  __hash_create(handle->node_index,
                handle->node_index_size,
                (hash_key_f)hash_key_string,
                (hash_cmp_f)strcmp, 
                NULL);
  
  handle->attr_index_size = GENDERS_ATTR_INDEX_INIT_SIZE;
  
  __hash_create(handle->attr_index,
                handle->attr_index_size,
                (hash_key_f)hash_key_string,
                (hash_cmp_f)strcmp, 
                (hash_del_f)list_destroy);

  if (_genders_open_and_parse(handle, 
			      filename, 
			      &handle->numattrs,
			      &handle->maxattrs,
			      &handle->maxnodelen,
			      &handle->maxattrlen,
			      &handle->maxvallen,
			      handle->nodeslist, 
			      handle->attrvalslist,
			      handle->attrslist,
                              &(handle->node_index),
                              &(handle->node_index_size),
                              &(handle->attr_index),
                              &(handle->attr_index_size),
			      0, 
			      NULL) < 0)
    goto cleanup;

  handle->numnodes = list_count(handle->nodeslist);

  if (gethostname(handle->nodename, GENDERS_MAXHOSTNAMELEN+1) < 0) 
    {
      handle->errnum = GENDERS_ERR_INTERNAL;
      goto cleanup;
    }
  handle->nodename[GENDERS_MAXHOSTNAMELEN]='\0';

  /* shorten hostname if necessary */
#ifndef WITH_NON_SHORTENED_HOSTNAMES
  if ((temp = strchr(handle->nodename,'.')))
    *temp = '\0';
#endif /* !WITH_NON_SHORTENED_HOSTNAMES */
  
  handle->maxnodelen = GENDERS_MAX(strlen(handle->nodename), handle->maxnodelen);

  /* Create a buffer for value substitutions */
  __xmalloc(handle->valbuf, char *, handle->maxvallen + 1);

  handle->is_loaded++;
  handle->errnum = GENDERS_ERR_SUCCESS;
  return 0;

cleanup:
  if (handle && handle->magic == GENDERS_ERR_MAGIC) 
    {
      free(handle->valbuf);
      
      /* Can't pass NULL for key, so pass junk, _genders_list_is_all()
       * will ensure everything is deleted
       */
      list_delete_all(handle->nodeslist, _genders_list_is_all, ""); 
      list_delete_all(handle->attrvalslist, _genders_list_is_all, ""); 
      list_delete_all(handle->attrslist, _genders_list_is_all, ""); 
      __hash_destroy(handle->node_index);
      __hash_destroy(handle->attr_index);
      _initialize_handle_info(handle);
    }
  return -1;
}
Ejemplo n.º 21
0
void obj_free_half_list(list *listo)
{
	list_delete_all(listo);
	free(listo->names);
}
Ejemplo n.º 22
0
static int _partition_requested (List l, char *partition)
{
    if (l == NULL)
        return (0);
    return (list_delete_all (l, (ListFindF)_find_str, partition));
}