MINOR: session: factor out the connect time measurement
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.
diff --git a/src/session.c b/src/session.c
index 72daf61..c0b86b9 100644
--- a/src/session.c
+++ b/src/session.c
@@ -785,8 +785,6 @@
* 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 @@
/* 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 @@
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 @@
}
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;
}