]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: mux-h1: Correctly report Ti timer when HTX and keepalives are used
authorDave Pirotte <dpirotte@gmail.com>
Wed, 10 Jul 2019 13:57:38 +0000 (13:57 +0000)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 12 Jul 2019 14:14:12 +0000 (16:14 +0200)
When HTTP keepalives are used in conjunction with HTX, the Ti timer
reports the elapsed time since the beginning of the connection instead
of the end of the previous request as stated in the documentation. Th,
Tq and Tt also report incorrectly as a result.

When creating a new h1s, check if it is the first request on the
connection. If not, set the session create times to the current
timestamp rather than the initial session accept timestamp. This makes
the logged timers behave as stated in the documentation.

This fix should be backported to 1.9 and 2.0.

src/mux_h1.c

index c8db2637b91fbbb1e0c37ae1dfed24bf39cb9529..365c5ea025c3f9b2d0c3850886509ba3c8be3823 100644 (file)
@@ -306,10 +306,20 @@ static struct h1s *h1s_create(struct h1c *h1c, struct conn_stream *cs, struct se
                if (!sess)
                        sess = h1c->conn->owner;
 
-               h1s->csinfo.create_date = sess->accept_date;
-               h1s->csinfo.tv_create   = sess->tv_accept;
-               h1s->csinfo.t_handshake = sess->t_handshake;
-               h1s->csinfo.t_idle      = -1;
+               /* Timers for subsequent sessions on the same HTTP 1.x connection
+                * measure from `now`, not from the connection accept time */
+               if (h1s->flags & H1S_F_NOT_FIRST) {
+                       h1s->csinfo.create_date = date;
+                       h1s->csinfo.tv_create   = now;
+                       h1s->csinfo.t_handshake = 0;
+                       h1s->csinfo.t_idle      = -1;
+               }
+               else {
+                       h1s->csinfo.create_date = sess->accept_date;
+                       h1s->csinfo.tv_create   = sess->tv_accept;
+                       h1s->csinfo.t_handshake = sess->t_handshake;
+                       h1s->csinfo.t_idle      = -1;
+               }
        }
        else {
                if (h1c->px->options2 & PR_O2_RSPBUG_OK)