]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: counters: fix track-sc* to wait on unstable contents
authorWilly Tarreau <w@1wt.eu>
Wed, 25 Jun 2014 15:01:56 +0000 (17:01 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 25 Jun 2014 15:26:54 +0000 (17:26 +0200)
I've been facing multiple configurations which involved track-sc* rules
in tcp-request content without the "if ..." to force it to wait for the
contents, resulting in random behaviour with contents sometimes retrieved
and sometimes not.

Reading the doc doesn't make it clear either that the tracking will be
performed only if data are already there and that waiting on an ACL is
the only way to avoid this.

Since this behaviour is not natural and we now have the ability to fix
it, this patch ensures that if input data are still moving, instead of
silently dropping them, we naturally wait for them to stabilize up to
the inspect-delay. This way it's not needed anymore to implement an
ACL-based condition to force to wait for data, eventhough the behaviour
is not changed for when an ACL is present.

The most obvious usage will be when track-sc is followed by any HTTP
sample expression, there's no need anymore for adding "if HTTP".

It's probably worth backporting this to 1.5 to avoid further configuration
issues. Note that it requires previous patch.

src/proto_tcp.c

index 1aac0d9225d9e533c1f38463ba987cdef5fb1734..e9dbc9c0b6de03dc2b2e9a41966509a8a44d1f56 100644 (file)
@@ -1022,12 +1022,16 @@ int tcp_inspect_request(struct session *s, struct channel *req, int an_bit)
                                 * applies.
                                 */
                                struct stktable_key *key;
+                               struct sample smp;
 
                                if (stkctr_entry(&s->stkctr[tcp_trk_idx(rule->action)]))
                                        continue;
 
                                t = rule->act_prm.trk_ctr.table.t;
-                               key = stktable_fetch_key(t, s->be, s, &s->txn, SMP_OPT_DIR_REQ|SMP_OPT_FINAL, rule->act_prm.trk_ctr.expr, NULL);
+                               key = stktable_fetch_key(t, s->be, s, &s->txn, SMP_OPT_DIR_REQ | partial, rule->act_prm.trk_ctr.expr, &smp);
+
+                               if (smp.flags & SMP_F_MAY_CHANGE)
+                                       goto missing_data;
 
                                if (key && (ts = stktable_get_entry(t, key))) {
                                        session_track_stkctr(&s->stkctr[tcp_trk_idx(rule->action)], t, ts);