]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: http_ana: Report -1 for %Tr for invalid response only
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 18 Nov 2024 21:37:52 +0000 (22:37 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 19 Nov 2024 14:29:40 +0000 (15:29 +0100)
The server response time is erroneously reported as -1 when it is
intercepted by HAProxy.

As stated in the documentation, the server response time is reported as -1
when the last response header was never seen. It happens when a server
timeout is triggered before the server managed to process the request. It
also happens if the response is invalid. This may be reported by the mux
during the response parsing, but also by the HTTP analyzers. However, in
this last case, the response time must only be reported as -1 on 502.

This patch must be backported to all stable versions. It should fix the
issue #2384.

src/http_ana.c

index cda4642408c052e8f27cea17cb22ea91365be1fd..95b146ce324c95652601c64081d131dc50d04929 100644 (file)
@@ -1991,6 +1991,7 @@ int http_process_res_common(struct stream *s, struct channel *rep, int an_bit, s
        goto return_prx_err;
 
  return_bad_res:
+       s->logs.t_data = -1; /* was not a valid response */
        txn->status = 502;
        stream_inc_http_fail_ctr(s);
        _HA_ATOMIC_INC(&s->be->be_counters.failed_resp);
@@ -2006,7 +2007,6 @@ int http_process_res_common(struct stream *s, struct channel *rep, int an_bit, s
        /* fall through */
 
  return_prx_cond:
-       s->logs.t_data = -1; /* was not a valid response */
        s->scb->flags |= SC_FL_NOLINGER;
 
        http_set_term_flags(s);