]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] session: switch to established state if no connect function
authorWilly Tarreau <w@1wt.eu>
Sun, 16 Aug 2009 16:27:24 +0000 (18:27 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 16 Aug 2009 17:33:29 +0000 (19:33 +0200)
When a stream interface has no connect() function, it means it is
immediately connected, so we don't need any connection request.
This will be used with unix sockets.

src/session.c

index 1a187900211dc74d9e5e7b4c2c7875e34ef07d20..5197a80f751cf392ee744ec667837e0d2f643ed4 100644 (file)
@@ -1005,8 +1005,15 @@ resync_stream_interface:
        /* it's possible that an upper layer has requested a connection setup or abort */
        if (s->req->cons->state == SI_ST_INI &&
            (s->req->flags & (BF_WRITE_ENA|BF_SHUTW|BF_SHUTW_NOW))) {
-               if ((s->req->flags & (BF_WRITE_ENA|BF_SHUTW|BF_SHUTW_NOW)) == BF_WRITE_ENA)
-                       s->req->cons->state = SI_ST_REQ; /* new connection requested */
+               if ((s->req->flags & (BF_WRITE_ENA|BF_SHUTW|BF_SHUTW_NOW)) == BF_WRITE_ENA) {
+                       /* If we have a ->connect method, we need to perform a connection request,
+                        * otherwise we immediately switch to the connected state.
+                        */
+                       if (s->req->cons->connect)
+                               s->req->cons->state = SI_ST_REQ; /* new connection requested */
+                       else
+                               s->req->cons->state = SI_ST_EST; /* connection established */
+               }
                else
                        s->req->cons->state = SI_ST_CLO; /* shutw+ini = abort */
        }