]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] do not create a socket if there is no server
authorWilly Tarreau <w@1wt.eu>
Sat, 20 Jan 2007 10:07:46 +0000 (11:07 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 20 Jan 2007 10:07:46 +0000 (11:07 +0100)
Since the distinction of backends and frontends, it has become
possible that some requests reach a frontend which has no
backend parameters. We must not create a socket on the backend
side just to destroy it later in such a case. The real problem
comes from the dispatch mode not being explictly stated.

src/backend.c

index c0283d20a33107dd6c254ff516f048e14a6113b9..1601c408c7715897b385157b2bca3d1bdbbcde6b 100644 (file)
@@ -186,7 +186,10 @@ int assign_server(struct session *s)
                        else /* unknown balancing algorithm */
                                return SRV_STATUS_INTERNAL;
                }
-               s->flags |= SN_ASSIGNED;
+               else if (*(int *)&s->be->beprm->dispatch_addr.sin_addr || s->fe->options & PR_O_TRANSP)
+                       s->flags |= SN_ASSIGNED;
+               else
+                       return SRV_STATUS_NOSRV;
        }
        return SRV_STATUS_OK;
 }
@@ -243,6 +246,10 @@ int assign_server_address(struct session *s)
                        return SRV_STATUS_INTERNAL;
                }
        }
+       else {
+               /* no server and no LB algorithm ! */
+               return SRV_STATUS_INTERNAL;
+       }
 
        s->flags |= SN_ADDR_SET;
        return SRV_STATUS_OK;