diff --git a/include/haproxy/vars.h b/include/haproxy/vars.h index 30e6fe0c8..ebd1f1579 100644 --- a/include/haproxy/vars.h +++ b/include/haproxy/vars.h @@ -41,28 +41,32 @@ int vars_unset_by_name_ifexist(const char *name, size_t len, struct sample *smp) int vars_get_by_desc(const struct var_desc *var_desc, struct sample *smp, const struct buffer *def); int vars_check_arg(struct arg *arg, char **err); -/* locks the for writes */ +/* locks the for writes if it's in a shared scope */ static inline void vars_wrlock(struct vars *vars) { - HA_RWLOCK_WRLOCK(VARS_LOCK, &vars->rwlock); + if (vars->scope == SCOPE_PROC) + HA_RWLOCK_WRLOCK(VARS_LOCK, &vars->rwlock); } -/* unlocks the for writes */ +/* unlocks the for writes if it's in a shared scope */ static inline void vars_wrunlock(struct vars *vars) { - HA_RWLOCK_WRUNLOCK(VARS_LOCK, &vars->rwlock); + if (vars->scope == SCOPE_PROC) + HA_RWLOCK_WRUNLOCK(VARS_LOCK, &vars->rwlock); } -/* locks the for reads */ +/* locks the for reads if it's in a shared scope */ static inline void vars_rdlock(struct vars *vars) { - HA_RWLOCK_RDLOCK(VARS_LOCK, &vars->rwlock); + if (vars->scope == SCOPE_PROC) + HA_RWLOCK_RDLOCK(VARS_LOCK, &vars->rwlock); } -/* unlocks the for reads */ +/* unlocks the for reads if it's in a shared scope */ static inline void vars_rdunlock(struct vars *vars) { - HA_RWLOCK_RDUNLOCK(VARS_LOCK, &vars->rwlock); + if (vars->scope == SCOPE_PROC) + HA_RWLOCK_RDUNLOCK(VARS_LOCK, &vars->rwlock); } #endif