Example #1
0
/* If no specified variable exist, safe_set_env will create one, else it only modify the value */
static void _safe_set_env(const char *name, unsigned long long value,  enum envtype Type, void* ptr, size_t size )
{
	struct env_struct *var;
    
	var = find_env(name);
    
    if (!var) {
        if (Type == kEnvPtr) {
            _set_env(name, 0, kEnvPtr,ptr,size);
        } 
        else if (Type == kEnvValue) {
            _set_env(name, value, kEnvValue,0,0);
        }
    } 
    else if (var->Type != Type) {
        return;        
	}     
    else {
        if (Type == kEnvValue) 
            var->value = value;
        else if (Type == kEnvPtr)
            _re_set_env_copy(var,ptr,size);            
    }
	
	return;    
}
Example #2
0
/*
 * Set environment variables as appropriate for a job (i.e. all tasks) based
 * upon the job step's GRES state.
 */
extern void step_set_env(char ***step_env_ptr, void *gres_ptr)
{
	static int local_inx = 0;
	static bool already_seen = false;

	_set_env(step_env_ptr, gres_ptr, 0, NULL,
		 &already_seen, &local_inx, false, false);
}
Example #3
0
/*
 * Reset environment variables as appropriate for a job (i.e. this one tasks)
 * based upon the job step's GRES state and assigned CPUs.
 */
extern void step_reset_env(char ***step_env_ptr, void *gres_ptr,
			   bitstr_t *usable_gres)
{
	static int local_inx = 0;
	static bool already_seen = false;

	_set_env(step_env_ptr, gres_ptr, 0, usable_gres,
		 &already_seen, &local_inx, true, false);
}
Example #4
0
/*
 * Set environment variables as appropriate for a job (i.e. all tasks) based
 * upon the job's GRES state.
 */
extern void job_set_env(char ***job_env_ptr, void *gres_ptr, int node_inx)
{
	/*
	 * Variables are not static like in step_*_env since we could be calling
	 * this from the slurmd where we are dealing with a different job each
	 * time we hit this function, so we don't want to keep track of other
	 * unrelated job's status.  This can also get called multiple times
	 * (different prologs and such) which would also result in bad info each
	 * call after the first.
	 */
	int local_inx = 0;
	bool already_seen = false;

	_set_env(job_env_ptr, gres_ptr, node_inx, NULL,
		 &already_seen, &local_inx, false, true);
}
Example #5
0
void set_env_copy(const char *name, void * ptr, size_t size ) {
    _set_env(name, 0, kEnvPtr,ptr,size);
}
Example #6
0
/* Warning: set_env will create a new variable each time it will be called, 
 * if you want to set again an existing variable, please use safe_set_env or re_set_env .
 * NOTE: If you set several times the "same variable" by using this function,
 * the HASH_COUNT will grow up, 
 * but hopefully find_env will return the last variable that you have set with the same name
 * ex: set_env("test",10);
 *     set_env("test",20);
 *
 *    HASH_COUNT will be equal to 2, get_env("test") will return 20
 *
 *    safe_set_env("test",10);
 *    safe_set_env("test",20);
 * 
 *    HASH_COUNT will be equal to 1, get_env("test") will return 20
 *
 *    set_env("test",10);
 *    re_set_env("test",20);
 *
 *    HASH_COUNT will be equal to 1, get_env("test") will return 20
 *
 */
void set_env(const char *name, unsigned long value ) {
    _set_env(name, value, kEnvValue,0,0);
}