]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MEDIUM] session: finish session establishment sequence in with I/O handlers
authorWilly Tarreau <w@1wt.eu>
Mon, 31 May 2010 09:57:51 +0000 (11:57 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 14 Jun 2010 08:53:14 +0000 (10:53 +0200)
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

index d5dbff247d7e86988f65d5fd2f072c13ffcf357c..ec8d07b38e0592098506959226e10eb0ab8e1deb 100644 (file)
@@ -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 {