Example #1
0
/**************************************************************************\
 * To test for memory leaks, set MEMORY_LEAK_DEBUG to 1 using
 * "configure --enable-memory-leak-debug" then execute
 * $ valgrind --tool=memcheck --leak-check=yes --num-callers=8 \
 *   --leak-resolution=med ./slurmd -Dc >valg.slurmd.out 2>&1
 *
 * Then exercise the slurmd functionality before executing
 * > scontrol shutdown
 *
 * All allocated memory should be freed
\**************************************************************************/
static int
_slurmd_fini(void)
{
	switch_g_node_fini();
	jobacct_gather_fini();
	acct_gather_profile_fini();
	save_cred_state(conf->vctx);
	switch_fini();
	slurmd_task_fini();
	slurm_conf_destroy();
	slurm_proctrack_fini();
	slurm_auth_fini();
	node_fini2();
	gres_plugin_fini();
	slurm_topo_fini();
	slurmd_req(NULL);	/* purge memory allocated by slurmd_req() */
	fini_setproctitle();
	slurm_select_fini();
	spank_slurmd_exit();
	cpu_freq_fini();
	job_container_fini();
	acct_gather_conf_destroy();

	return SLURM_SUCCESS;
}
Example #2
0
/*
 * Initialize the job container plugin.
 *
 * RET - slurm error code
 */
extern int job_container_init(void)
{
    int retval = SLURM_SUCCESS;
    char *plugin_type = "job_container";
    char *container_plugin_type = NULL;
    char *last = NULL, *job_container_plugin_list, *job_container = NULL;

    if (init_run && (g_container_context_num >= 0))
        return retval;

    slurm_mutex_lock(&g_container_context_lock);

    if (g_container_context_num >= 0)
        goto done;

    container_plugin_type = slurm_get_job_container_plugin();
    g_container_context_num = 0; /* mark it before anything else */
    if ((container_plugin_type == NULL) ||
            (container_plugin_type[0] == '\0'))
        goto done;

    job_container_plugin_list = container_plugin_type;
    while ((job_container =
                strtok_r(job_container_plugin_list, ",", &last))) {
        xrealloc(ops,
                 sizeof(job_container_ops_t) *
                 (g_container_context_num + 1));
        xrealloc(g_container_context, (sizeof(plugin_context_t *)
                                       * (g_container_context_num + 1)));
        if (strncmp(job_container, "job_container/", 14) == 0)
            job_container += 14; /* backward compatibility */
        job_container = xstrdup_printf("job_container/%s",
                                       job_container);
        g_container_context[g_container_context_num] =
            plugin_context_create(
                plugin_type, job_container,
                (void **)&ops[g_container_context_num],
                syms, sizeof(syms));
        if (!g_container_context[g_container_context_num]) {
            error("cannot create %s context for %s",
                  plugin_type, job_container);
            xfree(job_container);
            retval = SLURM_ERROR;
            break;
        }

        xfree(job_container);
        g_container_context_num++;
        job_container_plugin_list = NULL; /* for next iteration */
    }
    init_run = true;

done:
    slurm_mutex_unlock(&g_container_context_lock);
    xfree(container_plugin_type);

    if (retval != SLURM_SUCCESS)
        job_container_fini();

    return retval;
}