From 85e7d00a708f24b925bffc62ef5bd5584caf034c Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 31 May 2010 11:57:51 +0200 Subject: [PATCH] [MEDIUM] session: finish session establishment sequence in with I/O handlers Calling sess_establish() upon a successful connect() was essential, but it was not clearly stated whether it was necessary for an access to an I/O handler or not. While it would be desired, having it automatically add the response analyzers is quite a problem, and it breaks HTTP stats. The solution is thus not to call it for now and to perform the few response initializations as needed. For the long term, we need to find a way to specify the analyzers to install during a stream_int_register_handler() if any. --- src/session.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/session.c b/src/session.c index d5dbff247d..ec8d07b38e 100644 --- a/src/session.c +++ b/src/session.c @@ -318,8 +318,8 @@ int sess_update_st_cer(struct session *s, struct stream_interface *si) /* * This function handles the transition between the SI_ST_CON state and the - * SI_ST_EST state. It must only be called after switching from SI_ST_CON to - * SI_ST_EST. + * SI_ST_EST state. It must only be called after switching from SI_ST_CON (or + * SI_ST_INI) to SI_ST_EST, but only when a ->connect function is defined. */ void sess_establish(struct session *s, struct stream_interface *si) { @@ -1370,13 +1370,16 @@ resync_stream_interface: if (s->req->cons->state == SI_ST_INI) { if (!(s->req->flags & BF_SHUTW)) { if ((s->req->flags & (BF_AUTO_CONNECT|BF_OUT_EMPTY)) != BF_OUT_EMPTY) { - /* If we have a ->connect method, we need to perform a connection request, - * otherwise we immediately switch to the connected state. + /* If we have an iohandler without a connect method, we immediately + * switch to the connected state, otherwise we perform a connection + * request. */ - if (s->req->cons->connect) - s->req->cons->state = SI_ST_REQ; /* new connection requested */ - else + s->req->cons->state = SI_ST_REQ; /* new connection requested */ + if (unlikely(s->req->cons->iohandler && !s->req->cons->connect)) { s->req->cons->state = SI_ST_EST; /* connection established */ + s->rep->flags |= BF_READ_ATTACHED; /* producer is now attached */ + s->req->wex = TICK_ETERNITY; + } } } else { -- 2.47.3