[MEDIUM] removed now unused fiprm and beprm from proxies
The fiprm and beprm were added to ease the transition between
a single listener mode to frontends+backends. They are no longer
needed and make the code a bit more complicated. Remove them.
diff --git a/src/backend.c b/src/backend.c
index 309bee1..ff02443 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -160,20 +160,20 @@
return SRV_STATUS_INTERNAL;
if (!(s->flags & SN_ASSIGNED)) {
- if (s->be->beprm->options & PR_O_BALANCE) {
+ if (s->be->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)
+ if (!s->be->srv_act && !s->be->srv_bck)
return SRV_STATUS_NOSRV;
- if (s->be->beprm->options & PR_O_BALANCE_RR) {
- s->srv = get_server_rr_with_conns(s->be->beprm);
+ if (s->be->options & PR_O_BALANCE_RR) {
+ s->srv = get_server_rr_with_conns(s->be);
if (!s->srv)
return SRV_STATUS_FULL;
}
- else if (s->be->beprm->options & PR_O_BALANCE_SH) {
+ else if (s->be->options & PR_O_BALANCE_SH) {
int len;
if (s->cli_addr.ss_family == AF_INET)
@@ -183,14 +183,14 @@
else /* unknown IP family */
return SRV_STATUS_INTERNAL;
- s->srv = get_server_sh(s->be->beprm,
+ s->srv = get_server_sh(s->be,
(void *)&((struct sockaddr_in *)&s->cli_addr)->sin_addr,
len);
}
else /* unknown balancing algorithm */
return SRV_STATUS_INTERNAL;
}
- else if (!*(int *)&s->be->beprm->dispatch_addr.sin_addr &&
+ else if (!*(int *)&s->be->dispatch_addr.sin_addr &&
!(s->fe->options & PR_O_TRANSP)) {
return SRV_STATUS_NOSRV;
}
@@ -219,7 +219,7 @@
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->options & PR_O_BALANCE)) {
/* A server is necessarily known for this session */
if (!(s->flags & SN_ASSIGNED))
return SRV_STATUS_INTERNAL;
@@ -238,9 +238,9 @@
s->srv_addr.sin_port = htons(ntohs(s->srv_addr.sin_port) + ntohs(sockname.sin_port));
}
}
- else if (*(int *)&s->be->beprm->dispatch_addr.sin_addr) {
+ else if (*(int *)&s->be->dispatch_addr.sin_addr) {
/* connect to the defined dispatch addr */
- s->srv_addr = s->be->beprm->dispatch_addr;
+ s->srv_addr = s->be->dispatch_addr;
}
else if (s->fe->options & PR_O_TRANSP) {
/* in transparent mode, use the original dest addr if no dispatch specified */
@@ -356,17 +356,17 @@
qfprintf(stderr, "Cannot get a server socket.\n");
if (errno == ENFILE)
- send_log(s->be->beprm, LOG_EMERG,
+ send_log(s->be, LOG_EMERG,
"Proxy %s reached system FD limit at %d. Please check system tunables.\n",
- s->be->beprm->id, maxfd);
+ s->be->id, maxfd);
else if (errno == EMFILE)
- send_log(s->be->beprm, LOG_EMERG,
+ send_log(s->be, LOG_EMERG,
"Proxy %s reached process FD limit at %d. Please check 'ulimit-n' and restart.\n",
- s->be->beprm->id, maxfd);
+ s->be->id, maxfd);
else if (errno == ENOBUFS || errno == ENOMEM)
- send_log(s->be->beprm, LOG_EMERG,
+ send_log(s->be, LOG_EMERG,
"Proxy %s reached system memory limit at %d sockets. Please check system tunables.\n",
- s->be->beprm->id, maxfd);
+ s->be->id, maxfd);
/* this is a resource error */
return SN_ERR_RESOURCE;
}
@@ -381,7 +381,7 @@
}
#ifdef CONFIG_HAP_TCPSPLICE
- if ((s->fe->options & s->be->beprm->options) & PR_O_TCPSPLICE) {
+ if ((s->fe->options & s->be->options) & PR_O_TCPSPLICE) {
/* TCP splicing supported by both FE and BE */
tcp_splice_initfd(s->cli_fd, fd);
}
@@ -394,7 +394,7 @@
return SN_ERR_INTERNAL;
}
- if (s->be->beprm->options & PR_O_TCP_SRV_KA)
+ if (s->be->options & PR_O_TCP_SRV_KA)
setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (char *) &one, sizeof(one));
/* allow specific binding :
@@ -405,11 +405,11 @@
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof(one));
if (bind(fd, (struct sockaddr *)&s->srv->source_addr, sizeof(s->srv->source_addr)) == -1) {
Alert("Cannot bind to source address before connect() for server %s/%s. Aborting.\n",
- s->be->beprm->id, s->srv->id);
+ s->be->id, s->srv->id);
close(fd);
- send_log(s->be->beprm, LOG_EMERG,
+ send_log(s->be, LOG_EMERG,
"Cannot bind to source address before connect() for server %s/%s.\n",
- s->be->beprm->id, s->srv->id);
+ s->be->id, s->srv->id);
return SN_ERR_RESOURCE;
}
#ifdef CONFIG_HAP_CTTPROXY
@@ -439,33 +439,33 @@
if (setsockopt(fd, SOL_IP, IP_TPROXY, &itp1, sizeof(itp1)) == -1 ||
setsockopt(fd, SOL_IP, IP_TPROXY, &itp2, sizeof(itp2)) == -1) {
Alert("Cannot bind to tproxy source address before connect() for server %s/%s. Aborting.\n",
- s->be->beprm->id, s->srv->id);
+ s->be->id, s->srv->id);
close(fd);
- send_log(s->be->beprm, LOG_EMERG,
+ send_log(s->be, LOG_EMERG,
"Cannot bind to tproxy source address before connect() for server %s/%s.\n",
- s->be->beprm->id, s->srv->id);
+ s->be->id, s->srv->id);
return SN_ERR_RESOURCE;
}
}
#endif
}
- else if (s->be->beprm->options & PR_O_BIND_SRC) {
+ else if (s->be->options & PR_O_BIND_SRC) {
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof(one));
- if (bind(fd, (struct sockaddr *)&s->be->beprm->source_addr, sizeof(s->be->beprm->source_addr)) == -1) {
- Alert("Cannot bind to source address before connect() for proxy %s. Aborting.\n", s->be->beprm->id);
+ if (bind(fd, (struct sockaddr *)&s->be->source_addr, sizeof(s->be->source_addr)) == -1) {
+ Alert("Cannot bind to source address before connect() for proxy %s. Aborting.\n", s->be->id);
close(fd);
- send_log(s->be->beprm, LOG_EMERG,
+ send_log(s->be, LOG_EMERG,
"Cannot bind to source address before connect() for server %s/%s.\n",
- s->be->beprm->id, s->srv->id);
+ s->be->id, s->srv->id);
return SN_ERR_RESOURCE;
}
#ifdef CONFIG_HAP_CTTPROXY
- if (s->be->beprm->options & PR_O_TPXY_MASK) {
+ if (s->be->options & PR_O_TPXY_MASK) {
struct in_tproxy itp1, itp2;
memset(&itp1, 0, sizeof(itp1));
itp1.op = TPROXY_ASSIGN;
- switch (s->be->beprm->options & PR_O_TPXY_MASK) {
+ switch (s->be->options & PR_O_TPXY_MASK) {
case PR_O_TPXY_ADDR:
itp1.v.addr.faddr = s->srv->tproxy_addr.sin_addr;
itp1.v.addr.fport = s->srv->tproxy_addr.sin_port;
@@ -486,11 +486,11 @@
if (setsockopt(fd, SOL_IP, IP_TPROXY, &itp1, sizeof(itp1)) == -1 ||
setsockopt(fd, SOL_IP, IP_TPROXY, &itp2, sizeof(itp2)) == -1) {
Alert("Cannot bind to tproxy source address before connect() for proxy %s. Aborting.\n",
- s->be->beprm->id);
+ s->be->id);
close(fd);
- send_log(s->be->beprm, LOG_EMERG,
+ send_log(s->be, LOG_EMERG,
"Cannot bind to tproxy source address before connect() for server %s/%s.\n",
- s->be->beprm->id, s->srv->id);
+ s->be->id, s->srv->id);
return SN_ERR_RESOURCE;
}
}
@@ -509,9 +509,9 @@
qfprintf(stderr,"Cannot connect: %s.\n",msg);
close(fd);
- send_log(s->be->beprm, LOG_EMERG,
+ send_log(s->be, LOG_EMERG,
"Connect() failed for server %s/%s: %s.\n",
- s->be->beprm->id, s->srv->id, msg);
+ s->be->id, s->srv->id, msg);
return SN_ERR_RESOURCE;
} else if (errno == ETIMEDOUT) {
//qfprintf(stderr,"Connect(): ETIMEDOUT");
@@ -547,8 +547,8 @@
s->srv->cur_sess_max = s->srv->cur_sess;
}
- if (s->be->beprm->contimeout)
- tv_delayfrom(&s->req->cex, &now, s->be->beprm->contimeout);
+ if (s->be->contimeout)
+ tv_delayfrom(&s->req->cex, &now, s->be->contimeout);
else
tv_eternity(&s->req->cex);
return SN_ERR_NONE; /* connection is OK */
@@ -572,12 +572,12 @@
503, error_message(t, HTTP_ERR_503));
if (t->srv)
t->srv->failed_conns++;
- t->be->beprm->failed_conns++;
+ t->be->failed_conns++;
/* We used to have a free connection slot. Since we'll never use it,
* we have to inform the server that it may be used by another session.
*/
- if (may_dequeue_tasks(t->srv, t->be->beprm))
+ if (may_dequeue_tasks(t->srv, t->be))
task_wakeup(&rq, t->srv->queue_mgt);
return 1;
}
@@ -614,9 +614,9 @@
500, error_message(t, HTTP_ERR_500));
if (t->srv)
t->srv->failed_conns++;
- t->be->beprm->failed_conns++;
+ t->be->failed_conns++;
/* release other sessions waiting for this server */
- if (may_dequeue_tasks(t->srv, t->be->beprm))
+ if (may_dequeue_tasks(t->srv, t->be))
task_wakeup(&rq, t->srv->queue_mgt);
return 1;
}
@@ -624,18 +624,18 @@
if (srv_count_retry_down(t, conn_err)) {
return 1;
}
- } while (t->srv == NULL || t->conn_retries > 0 || !(t->be->beprm->options & PR_O_REDISP));
+ } while (t->srv == NULL || t->conn_retries > 0 || !(t->be->options & PR_O_REDISP));
/* We're on our last chance, and the REDISP option was specified.
* We will ignore cookie and force to balance or use the dispatcher.
*/
/* let's try to offer this slot to anybody */
- if (may_dequeue_tasks(t->srv, t->be->beprm))
+ if (may_dequeue_tasks(t->srv, t->be))
task_wakeup(&rq, t->srv->queue_mgt);
if (t->srv)
t->srv->failed_conns++;
- t->be->beprm->failed_conns++;
+ t->be->failed_conns++;
t->flags &= ~(SN_DIRECT | SN_ASSIGNED | SN_ADDR_SET);
t->srv = NULL; /* it's left to the dispatcher to choose a server */
@@ -671,14 +671,14 @@
503, error_message(t, HTTP_ERR_503));
if (t->srv)
t->srv->failed_conns++;
- t->be->beprm->failed_conns++;
+ t->be->failed_conns++;
return 1;
case SRV_STATUS_QUEUED:
/* FIXME-20060503 : we should use the queue timeout instead */
- if (t->be->beprm->contimeout)
- tv_delayfrom(&t->req->cex, &now, t->be->beprm->contimeout);
+ if (t->be->contimeout)
+ tv_delayfrom(&t->req->cex, &now, t->be->contimeout);
else
tv_eternity(&t->req->cex);
t->srv_state = SV_STIDLE;
@@ -693,10 +693,10 @@
500, error_message(t, HTTP_ERR_500));
if (t->srv)
t->srv->failed_conns++;
- t->be->beprm->failed_conns++;
+ t->be->failed_conns++;
/* release other sessions waiting for this server */
- if (may_dequeue_tasks(t->srv, t->be->beprm))
+ if (may_dequeue_tasks(t->srv, t->be))
task_wakeup(&rq, t->srv->queue_mgt);
return 1;
}