Exemple #1
0
/*
 * Initialize the task plugin.
 *
 * RET - slurm error code
 */
extern int slurmd_task_init(void)
{
	int retval = SLURM_SUCCESS;
	char *task_plugin_type = NULL;

	slurm_mutex_lock( &g_task_context_lock );

	if ( g_task_context )
		goto done;

	task_plugin_type = slurm_get_task_plugin();
	g_task_context = _slurmd_task_context_create( task_plugin_type );
	if ( g_task_context == NULL ) {
		error( "cannot create task context for %s",
			 task_plugin_type );
		retval = SLURM_ERROR;
		goto done;
	}

	if ( _slurmd_task_get_ops( g_task_context ) == NULL ) {
		error( "cannot resolve task plugin operations" );
		_slurmd_task_context_destroy( g_task_context );
		g_task_context = NULL;
		retval = SLURM_ERROR;
	}

 done:
	slurm_mutex_unlock( &g_task_context_lock );
	xfree(task_plugin_type);
	return retval;
}
Exemple #2
0
/*
 * Initialize the task plugin.
 *
 * RET - slurm error code
 */
extern int slurmd_task_init(void)
{
	int retval = SLURM_SUCCESS, i;
	char *task_plugin_type = NULL;
	char *last = NULL, *task_plugin_list, *task_plugin = NULL;

	slurm_mutex_lock( &g_task_context_lock );

	if ( g_task_context_num >= 0 )
		goto done;

	task_plugin_type = slurm_get_task_plugin();
	g_task_context_num = 0; /* mark it before anything else */
	if (task_plugin_type == NULL || task_plugin_type[0] == '\0')
		goto done;

	task_plugin_list = task_plugin_type;
	while ((task_plugin = strtok_r(task_plugin_list, ",", &last))) {
		i = g_task_context_num++;
		xrealloc(g_task_context,
			 (sizeof(slurmd_task_context_t *) * g_task_context_num));
		if (strncmp(task_plugin, "task/", 5) == 0)
			task_plugin += 5; /* backward compatibility */
		task_plugin = xstrdup_printf("task/%s", task_plugin);
		g_task_context[i] = _slurmd_task_context_create( task_plugin );
		if ( g_task_context[i] == NULL ) {
			error( "cannot create task context for %s",
				 task_plugin );
			goto error;
		}

		if ( _slurmd_task_get_ops( g_task_context[i] ) == NULL ) {
			error( "cannot resolve task plugin operations for %s",
			       task_plugin );
			goto error;
		}
		xfree(task_plugin);
		task_plugin_list = NULL; /* for next iteration */
	}

 done:
	slurm_mutex_unlock( &g_task_context_lock );
	xfree(task_plugin_type);
	return retval;

error:
	xfree(task_plugin);
	retval = SLURM_ERROR;
	for (i = 0; i < g_task_context_num; i++)
		if (g_task_context[i])
			_slurmd_task_context_destroy(g_task_context[i]);
	xfree(g_task_context);
	g_task_context_num = -1;
	goto done;
}