]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: sample: fix sample_process handling of unstable data
authorWilly Tarreau <w@1wt.eu>
Thu, 25 Jul 2013 10:02:38 +0000 (12:02 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 25 Jul 2013 13:00:37 +0000 (15:00 +0200)
sample_process() used to return NULL on changing data, regardless of the
SMP_OPT_FINAL flag. Let's change this so that it is now possible to
include such data in logs or HTTP headers. Also, one unconvenient
thing was that it used to always set the sample flags to zero, making
it incompatible with ACLs which may need to call it multiple times. Only
do this for locally-allocated samples.

src/sample.c

index 433a7ad35cbae6b8a43fc63692d5538bed44275c..fdf5400917900afb4d4f8b0b85ad8d733afa9bdc 100644 (file)
@@ -770,14 +770,15 @@ struct sample *sample_process(struct proxy *px, struct session *l4, void *l7,
 {
        struct sample_conv_expr *conv_expr;
 
-       if (p == NULL)
+       if (p == NULL) {
                p = &temp_smp;
+               p->flags = 0;
+       }
 
-       p->flags = 0;
        if (!expr->fetch->process(px, l4, l7, opt, expr->arg_p, p))
                return NULL;
 
-       if (p->flags & SMP_F_MAY_CHANGE)
+       if ((p->flags & SMP_F_MAY_CHANGE) && !(opt & SMP_OPT_FINAL))
                return NULL; /* we can only use stable samples */
 
        list_for_each_entry(conv_expr, &expr->conv_exprs, list) {