/src/haproxy/include/haproxy/vars.h
Line | Count | Source |
1 | | /* |
2 | | * include/haproxy/vars.h |
3 | | * Prototypes for variables. |
4 | | * |
5 | | * Copyright (C) 2015 Thierry FOURNIER <tfournier@arpalert.org> |
6 | | * |
7 | | * This library is free software; you can redistribute it and/or |
8 | | * modify it under the terms of the GNU Lesser General Public |
9 | | * License as published by the Free Software Foundation, version 2.1 |
10 | | * exclusively. |
11 | | * |
12 | | * This library is distributed in the hope that it will be useful, |
13 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | | * Lesser General Public License for more details. |
16 | | * |
17 | | * You should have received a copy of the GNU Lesser General Public |
18 | | * License along with this library; if not, write to the Free Software |
19 | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
20 | | */ |
21 | | |
22 | | #ifndef _HAPROXY_VARS_H |
23 | | #define _HAPROXY_VARS_H |
24 | | |
25 | | #include <import/ceb64_tree.h> |
26 | | |
27 | | #include <haproxy/api-t.h> |
28 | | #include <haproxy/session-t.h> |
29 | | #include <haproxy/stream-t.h> |
30 | | #include <haproxy/thread.h> |
31 | | #include <haproxy/vars-t.h> |
32 | | |
33 | | extern struct vars proc_vars; |
34 | | struct sample; |
35 | | struct arg; |
36 | | |
37 | | void vars_init_head(struct vars *vars, enum vars_scope scope); |
38 | | void var_accounting_diff(struct vars *vars, struct session *sess, struct stream *strm, int size); |
39 | | unsigned int var_clear(struct vars *vars, struct var *var, int force); |
40 | | void vars_prune_per_sess(struct vars *vars); |
41 | | int var_set(const struct var_desc *desc, struct sample *smp, uint flags); |
42 | | int var_unset(const struct var_desc *desc, struct sample *smp); |
43 | | int vars_get_by_name(const char *name, size_t len, struct sample *smp, const struct buffer *def); |
44 | | int vars_set_by_name_ifexist(const char *name, size_t len, struct sample *smp); |
45 | | int vars_set_by_name(const char *name, size_t len, struct sample *smp); |
46 | | int vars_unset_by_name_ifexist(const char *name, size_t len, struct sample *smp); |
47 | | int vars_get_by_desc(const struct var_desc *var_desc, struct sample *smp, const struct buffer *def); |
48 | | int vars_check_arg(struct arg *arg, char **err); |
49 | | |
50 | | /* locks the <vars> for writes if it's in a shared scope */ |
51 | | static inline void vars_wrlock(struct vars *vars) |
52 | 0 | { |
53 | 0 | if (vars->scope == SCOPE_PROC) |
54 | 0 | HA_RWLOCK_WRLOCK(VARS_LOCK, &vars->rwlock); |
55 | 0 | } Unexecuted instantiation: haproxy.c:vars_wrlock Unexecuted instantiation: http_ana.c:vars_wrlock Unexecuted instantiation: resolvers.c:vars_wrlock Unexecuted instantiation: sample.c:vars_wrlock Unexecuted instantiation: session.c:vars_wrlock Unexecuted instantiation: stream.c:vars_wrlock Unexecuted instantiation: tcpcheck.c:vars_wrlock Unexecuted instantiation: vars.c:vars_wrlock Unexecuted instantiation: check.c:vars_wrlock Unexecuted instantiation: flt_spoe.c:vars_wrlock |
56 | | |
57 | | /* unlocks the <vars> for writes if it's in a shared scope */ |
58 | | static inline void vars_wrunlock(struct vars *vars) |
59 | 0 | { |
60 | 0 | if (vars->scope == SCOPE_PROC) |
61 | 0 | HA_RWLOCK_WRUNLOCK(VARS_LOCK, &vars->rwlock); |
62 | 0 | } Unexecuted instantiation: haproxy.c:vars_wrunlock Unexecuted instantiation: http_ana.c:vars_wrunlock Unexecuted instantiation: resolvers.c:vars_wrunlock Unexecuted instantiation: sample.c:vars_wrunlock Unexecuted instantiation: session.c:vars_wrunlock Unexecuted instantiation: stream.c:vars_wrunlock Unexecuted instantiation: tcpcheck.c:vars_wrunlock Unexecuted instantiation: vars.c:vars_wrunlock Unexecuted instantiation: check.c:vars_wrunlock Unexecuted instantiation: flt_spoe.c:vars_wrunlock |
63 | | |
64 | | /* locks the <vars> for reads if it's in a shared scope */ |
65 | | static inline void vars_rdlock(struct vars *vars) |
66 | 0 | { |
67 | 0 | if (vars->scope == SCOPE_PROC) |
68 | 0 | HA_RWLOCK_RDLOCK(VARS_LOCK, &vars->rwlock); |
69 | 0 | } Unexecuted instantiation: haproxy.c:vars_rdlock Unexecuted instantiation: http_ana.c:vars_rdlock Unexecuted instantiation: resolvers.c:vars_rdlock Unexecuted instantiation: sample.c:vars_rdlock Unexecuted instantiation: session.c:vars_rdlock Unexecuted instantiation: stream.c:vars_rdlock Unexecuted instantiation: tcpcheck.c:vars_rdlock Unexecuted instantiation: vars.c:vars_rdlock Unexecuted instantiation: check.c:vars_rdlock Unexecuted instantiation: flt_spoe.c:vars_rdlock |
70 | | |
71 | | /* unlocks the <vars> for reads if it's in a shared scope */ |
72 | | static inline void vars_rdunlock(struct vars *vars) |
73 | 0 | { |
74 | 0 | if (vars->scope == SCOPE_PROC) |
75 | 0 | HA_RWLOCK_RDUNLOCK(VARS_LOCK, &vars->rwlock); |
76 | 0 | } Unexecuted instantiation: haproxy.c:vars_rdunlock Unexecuted instantiation: http_ana.c:vars_rdunlock Unexecuted instantiation: resolvers.c:vars_rdunlock Unexecuted instantiation: sample.c:vars_rdunlock Unexecuted instantiation: session.c:vars_rdunlock Unexecuted instantiation: stream.c:vars_rdunlock Unexecuted instantiation: tcpcheck.c:vars_rdunlock Unexecuted instantiation: vars.c:vars_rdunlock Unexecuted instantiation: check.c:vars_rdunlock Unexecuted instantiation: flt_spoe.c:vars_rdunlock |
77 | | |
78 | | /* This function free all the memory used by all the variables |
79 | | * in the list. |
80 | | */ |
81 | | static inline void vars_prune(struct vars *vars, struct session *sess, struct stream *strm) |
82 | 0 | { |
83 | 0 | struct var *var; |
84 | 0 | unsigned int size = 0; |
85 | 0 | int i; |
86 | |
|
87 | 0 | for (i = 0; i < VAR_NAME_ROOTS; i++) { |
88 | 0 | while ((var = cebu64_item_first(&vars->name_root[i], name_node, name_hash, struct var))) |
89 | 0 | size += var_clear(vars, var, 1); |
90 | 0 | } |
91 | |
|
92 | 0 | if (!size) |
93 | 0 | return; |
94 | | |
95 | 0 | var_accounting_diff(vars, sess, strm, -size); |
96 | 0 | } Unexecuted instantiation: haproxy.c:vars_prune Unexecuted instantiation: http_ana.c:vars_prune Unexecuted instantiation: resolvers.c:vars_prune Unexecuted instantiation: sample.c:vars_prune Unexecuted instantiation: session.c:vars_prune Unexecuted instantiation: stream.c:vars_prune Unexecuted instantiation: tcpcheck.c:vars_prune Unexecuted instantiation: vars.c:vars_prune Unexecuted instantiation: check.c:vars_prune Unexecuted instantiation: flt_spoe.c:vars_prune |
97 | | |
98 | | #endif |