]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUG] last backend change broke server assignment
authorWilly Tarreau <w@1wt.eu>
Sun, 21 Jan 2007 11:47:26 +0000 (12:47 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 21 Jan 2007 11:47:26 +0000 (12:47 +0100)
Due to a change in the if/else paths, s->flags did not receive
the SN_ASSIGNED value anymore.

src/backend.c

index 1601c408c7715897b385157b2bca3d1bdbbcde6b..68f2925761eb1e4dcfe2952669a1a1114202be85 100644 (file)
@@ -160,7 +160,11 @@ int assign_server(struct session *s)
                return SRV_STATUS_INTERNAL;
 
        if (!(s->flags & SN_ASSIGNED)) {
-               if ((s->be->beprm->options & PR_O_BALANCE) && !(s->flags & SN_DIRECT)) {
+               if (s->be->beprm->options & PR_O_BALANCE) {
+                       if (s->flags & SN_DIRECT) {
+                               s->flags |= SN_ASSIGNED;
+                               return SRV_STATUS_OK;
+                       }
                        if (!s->be->beprm->srv_act && !s->be->beprm->srv_bck)
                                return SRV_STATUS_NOSRV;
 
@@ -186,10 +190,11 @@ int assign_server(struct session *s)
                        else /* unknown balancing algorithm */
                                return SRV_STATUS_INTERNAL;
                }
-               else if (*(int *)&s->be->beprm->dispatch_addr.sin_addr || s->fe->options & PR_O_TRANSP)
-                       s->flags |= SN_ASSIGNED;
-               else
+               else if (!*(int *)&s->be->beprm->dispatch_addr.sin_addr &&
+                        !(s->fe->options & PR_O_TRANSP)) {
                        return SRV_STATUS_NOSRV;
+               }
+               s->flags |= SN_ASSIGNED;
        }
        return SRV_STATUS_OK;
 }
@@ -214,7 +219,7 @@ int assign_server_address(struct session *s)
        fprintf(stderr,"assign_server_address : s=%p\n",s);
 #endif
 
-       if (s->flags & SN_DIRECT || s->be->beprm->options & PR_O_BALANCE) {
+       if ((s->flags & SN_DIRECT) || (s->be->beprm->options & PR_O_BALANCE)) {
                /* A server is necessarily known for this session */
                if (!(s->flags & SN_ASSIGNED))
                        return SRV_STATUS_INTERNAL;