]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: session: prepare to support earlier transitions to the established state
authorWilly Tarreau <w@1wt.eu>
Tue, 31 Dec 2013 22:16:50 +0000 (23:16 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 31 Dec 2013 22:16:50 +0000 (23:16 +0100)
At the moment it is possible in sess_prepare_conn_req() to switch to the
established state when the target is an applet. But sess_update_stream_int()
will soon also have the ability to set the established state via
connect_server() when a connection is reused, leading to a synchronous
connect.

So prepare the code to handle this SI_ST_ASS -> SI_ST_EST transition, which
really matches what's done in the lower layers.

src/session.c

index c0b86b9b713149585d222259857644d204d6002a..de78e7e27e7b43c1bc3da5cd30b854699ecc5558 100644 (file)
@@ -2222,20 +2222,20 @@ struct task *process_session(struct task *t)
                         */
                        if (s->si[1].state != SI_ST_REQ)
                                sess_update_stream_int(s, &s->si[1]);
-                       if (s->si[1].state == SI_ST_REQ) {
+                       if (s->si[1].state == SI_ST_REQ)
                                sess_prepare_conn_req(s, &s->si[1]);
 
-                               /* applets directly go to the ESTABLISHED state */
-                               if (unlikely(s->si[1].state == SI_ST_EST))
-                                       sess_establish(s, &s->si[1]);
-
-                               /* Now we can add the server name to a header (if requested) */
-                               /* check for HTTP mode and proxy server_name_hdr_name != NULL */
-                               if ((s->flags & SN_BE_ASSIGNED) &&
-                                   (s->be->mode == PR_MODE_HTTP) &&
-                                   (s->be->server_id_hdr_name != NULL && objt_server(s->target))) {
-                                       http_send_name_header(&s->txn, s->be, objt_server(s->target)->id);
-                               }
+                       /* applets directly go to the ESTABLISHED state */
+                       if (unlikely(s->si[1].state == SI_ST_EST))
+                               sess_establish(s, &s->si[1]);
+
+                       /* Now we can add the server name to a header (if requested) */
+                       /* check for HTTP mode and proxy server_name_hdr_name != NULL */
+                       if ((s->si[1].state >= SI_ST_CON) &&
+                           (s->be->server_id_hdr_name != NULL) &&
+                           (s->be->mode == PR_MODE_HTTP) &&
+                           objt_server(s->target)) {
+                               http_send_name_header(&s->txn, s->be, objt_server(s->target)->id);
                        }
 
                        srv = objt_server(s->target);