* a bool (which is memory-less).
*
* Flags is a bitfield that may contain one of the following flags:
- * - VF_UPDATEONLY: if the scope is SCOPE_PROC, the variable may only be
- * updated but not created.
+ * - VF_UPDATEONLY: the variable may only be updated but not created.
* - VF_CREATEONLY: do nothing if the variable already exists (success).
* - VF_PERMANENT: this flag will be passed to the variable upon creation
*
-var->data.u.meth.str.data);
}
} else {
- /* creation permitted for proc ? */
- if (flags & VF_UPDATEONLY && scope == SCOPE_PROC)
+ if (flags & VF_UPDATEONLY)
goto unlock;
/* Check memory available. */
return 1;
}
-/* This function stores a sample in a variable if it was already defined.
+/* This function stores a sample in a variable unless it is of type "proc" and
+ * not defined yet.
* Returns zero on failure and non-zero otherwise. The variable not being
* defined is treated as a failure.
*/
if (!vars_hash_name(name, len, &scope, &hash, NULL))
return 0;
- return var_set(hash, scope, smp, VF_UPDATEONLY);
+ /* Variable creation is allowed for all scopes apart from the PROC one. */
+ return var_set(hash, scope, smp, (scope == SCOPE_PROC) ? VF_UPDATEONLY : 0);
}