]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: session: factor out the connect time measurement
authorWilly Tarreau <w@1wt.eu>
Tue, 31 Dec 2013 22:06:46 +0000 (23:06 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 31 Dec 2013 22:06:46 +0000 (23:06 +0100)
Currently there are 3 places in the code where t_connect is set after
switching to state SI_ST_EST, and a fourth one will soon come. Since
all these places lead to an immediate call to sess_establish() to
complete the session establishment, better move that measurement
there.

src/session.c

index 72daf6158050d5506a2d05862ebee19ee553533b..c0b86b9b713149585d222259857644d204d6002a 100644 (file)
@@ -785,8 +785,6 @@ static int sess_update_st_con_tcp(struct session *s, struct stream_interface *si
                         * so we need to pretend we're established to log correctly
                         * and let later states handle the failure.
                         */
-                       s->logs.t_connect = tv_ms_elapsed(&s->logs.tv_accept, &now);
-                       si->exp      = TICK_ETERNITY;
                        si->state    = SI_ST_EST;
                        si->err_type = SI_ET_DATA_ERR;
                        si->ib->flags |= CF_READ_ERROR | CF_WRITE_ERROR;
@@ -828,8 +826,6 @@ static int sess_update_st_con_tcp(struct session *s, struct stream_interface *si
        /* OK, this means that a connection succeeded. The caller will be
         * responsible for handling the transition from CON to EST.
         */
-       s->logs.t_connect = tv_ms_elapsed(&s->logs.tv_accept, &now);
-       si->exp      = TICK_ETERNITY;
        si->state    = SI_ST_EST;
        si->err_type = SI_ET_NONE;
        return 1;
@@ -929,6 +925,10 @@ static void sess_establish(struct session *s, struct stream_interface *si)
        struct channel *req = si->ob;
        struct channel *rep = si->ib;
 
+       /* First, centralize the timers information */
+       s->logs.t_connect = tv_ms_elapsed(&s->logs.tv_accept, &now);
+       si->exp      = TICK_ETERNITY;
+
        if (objt_server(s->target))
                health_adjust(objt_server(s->target), HANA_STATUS_L4_OK);
 
@@ -1188,10 +1188,8 @@ static void sess_prepare_conn_req(struct session *s, struct stream_interface *si
                }
 
                s->logs.t_queue   = tv_ms_elapsed(&s->logs.tv_accept, &now);
-               s->logs.t_connect = tv_ms_elapsed(&s->logs.tv_accept, &now);
                si->state         = SI_ST_EST;
                si->err_type      = SI_ET_NONE;
-               si->exp           = TICK_ETERNITY;
                /* let sess_establish() finish the job */
                return;
        }