]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: opentracing: only takes the variables lock on shared entries
authorMiroslav Zagorac <mzagorac@haproxy.com>
Wed, 23 Feb 2022 17:15:56 +0000 (18:15 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 8 Apr 2022 14:31:33 +0000 (16:31 +0200)
Regarding commit #61ecf2838:
  There's no point taking the variables locks for sess/txn/req/res
  contexts since these ones always run inside the same thread anyway.

This patch must be backported in 2.5.

addons/ot/src/vars.c

index 8769d54e75e16d679c1acd7f632ca7bc390e41b9..52fc1dfd6c922ca6d20d59498328884185d429cd 100644 (file)
@@ -44,10 +44,10 @@ static void flt_ot_vars_scope_dump(struct vars *vars, const char *scope)
        if (vars == NULL)
                return;
 
-       HA_RWLOCK_RDLOCK(VARS_LOCK, &(vars->rwlock));
+       vars_rdlock(vars);
        list_for_each_entry(var, &(vars->head), l)
                FLT_OT_DBG(2, "'%s.%s' -> '%.*s'", scope, var->name, (int)var->data.u.str.data, var->data.u.str.area);
-       HA_RWLOCK_RDUNLOCK(VARS_LOCK, &(vars->rwlock));
+       vars_rdunlock(vars);
 }
 
 
@@ -361,7 +361,7 @@ int flt_ot_vars_unset(struct stream *s, const char *scope, const char *prefix, u
 
        retval = 0;
 
-       HA_RWLOCK_WRLOCK(VARS_LOCK, &(vars->rwlock));
+       vars_wrlock(vars);
        list_for_each_entry_safe(var, var_back, &(vars->head), l) {
                FLT_OT_DBG(3, "variable cmp '%s' '%s' %d", var_prefix, var->name, var_prefix_len);
 
@@ -384,7 +384,7 @@ int flt_ot_vars_unset(struct stream *s, const char *scope, const char *prefix, u
                        retval++;
                }
        }
-       HA_RWLOCK_WRUNLOCK(VARS_LOCK, &(vars->rwlock));
+       vars_wrunlock(vars);
 
        FLT_OT_RETURN(retval);
 }
@@ -425,7 +425,7 @@ struct otc_text_map *flt_ot_vars_get(struct stream *s, const char *scope, const
        if (rc == -1)
                FLT_OT_RETURN(retptr);
 
-       HA_RWLOCK_RDLOCK(VARS_LOCK, &(vars->rwlock));
+       vars_rdlock(vars);
        list_for_each_entry(var, &(vars->head), l) {
                FLT_OT_DBG(3, "variable cmp '%s' '%s' %d", var_name, var->name, rc);
 
@@ -479,7 +479,7 @@ struct otc_text_map *flt_ot_vars_get(struct stream *s, const char *scope, const
                        }
                }
        }
-       HA_RWLOCK_RDUNLOCK(VARS_LOCK, &(vars->rwlock));
+       vars_rdunlock(vars);
 
        ot_text_map_show(retptr);