From: Willy Tarreau Date: Sat, 20 Jan 2007 10:07:46 +0000 (+0100) Subject: [MINOR] do not create a socket if there is no server X-Git-Tag: v1.3.6~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1a1158b0bda7bf9260260ae52148483feff22d09;p=thirdparty%2Fhaproxy.git [MINOR] do not create a socket if there is no server 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. --- diff --git a/src/backend.c b/src/backend.c index c0283d20a3..1601c408c7 100644 --- a/src/backend.c +++ b/src/backend.c @@ -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;