return SRV_STATUS_INTERNAL;
if (!(s->flags & SN_ASSIGNED)) {
- if ((s->be->options & PR_O_BALANCE) && !(s->flags & SN_DIRECT)) {
- if (!s->be->srv_act && !s->be->srv_bck)
+ if ((s->be->beprm->options & PR_O_BALANCE) && !(s->flags & SN_DIRECT)) {
+ if (!s->be->beprm->srv_act && !s->be->beprm->srv_bck)
return SRV_STATUS_NOSRV;
- if (s->be->options & PR_O_BALANCE_RR) {
- s->srv = get_server_rr_with_conns(s->be);
+ if (s->be->beprm->options & PR_O_BALANCE_RR) {
+ s->srv = get_server_rr_with_conns(s->be->beprm);
if (!s->srv)
return SRV_STATUS_FULL;
}
- else if (s->be->options & PR_O_BALANCE_SH) {
+ else if (s->be->beprm->options & PR_O_BALANCE_SH) {
int len;
if (s->cli_addr.ss_family == AF_INET)
else /* unknown IP family */
return SRV_STATUS_INTERNAL;
- s->srv = get_server_sh(s->be,
+ s->srv = get_server_sh(s->be->beprm,
(void *)&((struct sockaddr_in *)&s->cli_addr)->sin_addr,
len);
}
fprintf(stderr,"assign_server_address : s=%p\n",s);
#endif
- if (s->flags & SN_DIRECT || s->be->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;
s->srv_addr.sin_port = htons(ntohs(s->srv_addr.sin_port) + ntohs(sockname.sin_port));
}
}
- else if (*(int *)&s->be->dispatch_addr.sin_addr) {
+ else if (*(int *)&s->be->beprm->dispatch_addr.sin_addr) {
/* connect to the defined dispatch addr */
- s->srv_addr = s->be->dispatch_addr;
+ s->srv_addr = s->be->beprm->dispatch_addr;
}
else if (s->fe->options & PR_O_TRANSP) {
/* in transparent mode, use the original dest addr if no dispatch specified */
qfprintf(stderr, "Cannot get a server socket.\n");
if (errno == ENFILE)
- send_log(s->be, LOG_EMERG,
+ send_log(s->be->beprm, LOG_EMERG,
"Proxy %s reached system FD limit at %d. Please check system tunables.\n",
- s->be->id, maxfd);
+ s->be->beprm->id, maxfd);
else if (errno == EMFILE)
- send_log(s->be, LOG_EMERG,
+ send_log(s->be->beprm, LOG_EMERG,
"Proxy %s reached process FD limit at %d. Please check 'ulimit-n' and restart.\n",
- s->be->id, maxfd);
+ s->be->beprm->id, maxfd);
else if (errno == ENOBUFS || errno == ENOMEM)
- send_log(s->be, LOG_EMERG,
+ send_log(s->be->beprm, LOG_EMERG,
"Proxy %s reached system memory limit at %d sockets. Please check system tunables.\n",
- s->be->id, maxfd);
+ s->be->beprm->id, maxfd);
/* this is a resource error */
return SN_ERR_RESOURCE;
}
return SN_ERR_INTERNAL;
}
- if (s->be->options & PR_O_TCP_SRV_KA)
+ if (s->be->beprm->options & PR_O_TCP_SRV_KA)
setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (char *) &one, sizeof(one));
/* allow specific binding :
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->id, s->srv->id);
+ s->be->beprm->id, s->srv->id);
close(fd);
- send_log(s->be, LOG_EMERG,
+ send_log(s->be->beprm, LOG_EMERG,
"Cannot bind to source address before connect() for server %s/%s.\n",
- s->be->id, s->srv->id);
+ s->be->beprm->id, s->srv->id);
return SN_ERR_RESOURCE;
}
#ifdef CONFIG_HAP_CTTPROXY
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->id, s->srv->id);
+ s->be->beprm->id, s->srv->id);
close(fd);
- send_log(s->be, LOG_EMERG,
+ send_log(s->be->beprm, LOG_EMERG,
"Cannot bind to tproxy source address before connect() for server %s/%s.\n",
- s->be->id, s->srv->id);
+ s->be->beprm->id, s->srv->id);
return SN_ERR_RESOURCE;
}
}
#endif
}
- else if (s->be->options & PR_O_BIND_SRC) {
+ else if (s->be->beprm->options & PR_O_BIND_SRC) {
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof(one));
- 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);
+ 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);
close(fd);
- send_log(s->be, LOG_EMERG,
+ send_log(s->be->beprm, LOG_EMERG,
"Cannot bind to source address before connect() for server %s/%s.\n",
- s->be->id, s->srv->id);
+ s->be->beprm->id, s->srv->id);
return SN_ERR_RESOURCE;
}
#ifdef CONFIG_HAP_CTTPROXY
- if (s->be->options & PR_O_TPXY_MASK) {
+ if (s->be->beprm->options & PR_O_TPXY_MASK) {
struct in_tproxy itp1, itp2;
memset(&itp1, 0, sizeof(itp1));
itp1.op = TPROXY_ASSIGN;
- switch (s->be->options & PR_O_TPXY_MASK) {
+ switch (s->be->beprm->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;
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->id);
+ s->be->beprm->id);
close(fd);
- send_log(s->be, LOG_EMERG,
+ send_log(s->be->beprm, LOG_EMERG,
"Cannot bind to tproxy source address before connect() for server %s/%s.\n",
- s->be->id, s->srv->id);
+ s->be->beprm->id, s->srv->id);
return SN_ERR_RESOURCE;
}
}
qfprintf(stderr,"Cannot connect: %s.\n",msg);
close(fd);
- send_log(s->be, LOG_EMERG,
+ send_log(s->be->beprm, LOG_EMERG,
"Connect() failed for server %s/%s: %s.\n",
- s->be->id, s->srv->id, msg);
+ s->be->beprm->id, s->srv->id, msg);
return SN_ERR_RESOURCE;
} else if (errno == ETIMEDOUT) {
//qfprintf(stderr,"Connect(): ETIMEDOUT");
s->srv->cur_sess_max = s->srv->cur_sess;
}
- if (s->be->contimeout)
- tv_delayfrom(&s->req->cex, &now, s->be->contimeout);
+ if (s->be->beprm->contimeout)
+ tv_delayfrom(&s->req->cex, &now, s->be->beprm->contimeout);
else
tv_eternity(&s->req->cex);
return SN_ERR_NONE; /* connection is OK */
503, t->fe->errmsg.len503, t->fe->errmsg.msg503);
if (t->srv)
t->srv->failed_conns++;
- t->be->failed_conns++;
+ t->be->beprm->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))
+ if (may_dequeue_tasks(t->srv, t->be->beprm))
task_wakeup(&rq, t->srv->queue_mgt);
return 1;
}
500, t->fe->errmsg.len500, t->fe->errmsg.msg500);
if (t->srv)
t->srv->failed_conns++;
- t->be->failed_conns++;
+ t->be->beprm->failed_conns++;
/* release other sessions waiting for this server */
- if (may_dequeue_tasks(t->srv, t->be))
+ if (may_dequeue_tasks(t->srv, t->be->beprm))
task_wakeup(&rq, t->srv->queue_mgt);
return 1;
}
if (srv_count_retry_down(t, conn_err)) {
return 1;
}
- } while (t->srv == NULL || t->conn_retries > 0 || !(t->be->options & PR_O_REDISP));
+ } while (t->srv == NULL || t->conn_retries > 0 || !(t->be->beprm->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))
+ if (may_dequeue_tasks(t->srv, t->be->beprm))
task_wakeup(&rq, t->srv->queue_mgt);
if (t->srv)
t->srv->failed_conns++;
- t->be->failed_conns++;
+ t->be->beprm->failed_conns++;
t->flags &= ~(SN_DIRECT | SN_ASSIGNED | SN_ADDR_SET);
t->srv = NULL; /* it's left to the dispatcher to choose a server */
503, t->fe->errmsg.len503, t->fe->errmsg.msg503);
if (t->srv)
t->srv->failed_conns++;
- t->be->failed_conns++;
+ t->be->beprm->failed_conns++;
return 1;
case SRV_STATUS_QUEUED:
/* FIXME-20060503 : we should use the queue timeout instead */
- if (t->be->contimeout)
- tv_delayfrom(&t->req->cex, &now, t->be->contimeout);
+ if (t->be->beprm->contimeout)
+ tv_delayfrom(&t->req->cex, &now, t->be->beprm->contimeout);
else
tv_eternity(&t->req->cex);
t->srv_state = SV_STIDLE;
500, t->fe->errmsg.len500, t->fe->errmsg.msg500);
if (t->srv)
t->srv->failed_conns++;
- t->be->failed_conns++;
+ t->be->beprm->failed_conns++;
/* release other sessions waiting for this server */
- if (may_dequeue_tasks(t->srv, t->be))
+ if (may_dequeue_tasks(t->srv, t->be->beprm))
task_wakeup(&rq, t->srv->queue_mgt);
return 1;
}
if ((global.mode & MODE_DEBUG) && (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE))) {
int len;
len = sprintf(trash, "%08x:%s.closed[%04x:%04x]\n",
- s->uniq_id, s->be->id,
+ s->uniq_id, s->be->beprm->id,
(unsigned short)s->cli_fd, (unsigned short)s->srv_fd);
write(1, trash, len);
}
*/
char *sol, *eol; /* Start Of Line, End Of Line */
- struct proxy *rule_set;
+ struct proxy *cur_proxy;
eol = sol = req->data + t->hreq.eoh;
* consider that it's necessary after one single space.*/
struct cap_hdr *h;
int len;
- for (h = t->fi->req_cap; h; h = h->next) {
+ for (h = t->fe->fiprm->req_cap; h; h = h->next) {
if ((h->namelen + 2 <= eol - sol) &&
(sol[h->namelen] == ':') &&
(strncasecmp(sol, h->name, h->namelen) == 0)) {
* filters and various options. In order to support 3-level
* switching, here's how we should proceed :
*
- * a) run be->filters.
- * if (switch) then switch ->fi and ->be to the new backend.
- * b) run be->filters.
- * If there's another switch, then switch ->be to the new be.
- * c) run be->filters
+ * a) run be->fiprm.
+ * if (switch) then switch ->be to the new backend.
+ * b) run be->fiprm if (be != fe).
* There cannot be any switch from there, so ->be cannot be
* changed anymore.
*
- * => filters always apply to ->be, then ->be may change.
+ * => filters always apply to ->be, then ->be may change.
*
- * The response path will be able to apply either ->be, or
- * ->be then ->fi, or ->be then ->fi then ->fe filters in order
- * to match the reverse of the forward sequence.
+ * The response path will be able to apply either ->be, or
+ * ->be then ->fe filters in order to match the reverse of
+ * the forward sequence.
*/
do {
- rule_set = t->be;
+ struct proxy *rule_set = t->be->fiprm;
+ cur_proxy = t->be;
/* try headers filters */
if (rule_set->req_exp != NULL) {
return 1;
}
- } while (rule_set != t->be); /* we loop only if t->be has changed */
+ } while (cur_proxy != t->be); /* we loop only if t->be has changed */
/*
* Right now, we know that we have processed the entire headers
* and that unwanted requests have been filtered out. We can do
* whatever we want with the remaining request. Also, now we
- * may have separate values for ->fe, ->fi and ->be.
+ * may have separate values for ->fe, ->be.
*/
*/
/* It needs to look into the URI */
- if (t->be->appsession_name) {
+ if (t->be->beprm->appsession_name) {
get_srv_from_appsession(t,
t->hreq.start.str,
t->hreq.start.str + t->hreq.start.len);
/*
* 5: add X-Forwarded-For : Should depend on the backend only.
*/
- if (t->be->options & PR_O_FWDFOR) {
+ if (t->be->beprm->options & PR_O_FWDFOR) {
if (t->cli_addr.ss_family == AF_INET) {
int len;
unsigned char *pn;
if (!t->fe->clitimeout ||
- (t->srv_state < SV_STDATA && t->be->srvtimeout)) {
+ (t->srv_state < SV_STDATA && t->be->beprm->srvtimeout)) {
/* If the client has no timeout, or if the server is not ready yet,
* and we know for sure that it can expire, then it's cleaner to
* disable the timeout on the client side so that too low values
* if the client closes first.
*/
tv_delayfrom(&req->cex, &now,
- t->be->contimeout ? t->be->contimeout : 0);
+ t->be->beprm->contimeout ? t->be->beprm->contimeout : 0);
}
#if DEBUG_HTTP_PARSER
if (! MY_FD_ISSET(t->cli_fd, StaticReadEvent)) {
MY_FD_SET(t->cli_fd, StaticReadEvent);
if (!t->fe->clitimeout ||
- (t->srv_state < SV_STDATA && t->be->srvtimeout))
+ (t->srv_state < SV_STDATA && t->be->beprm->srvtimeout))
/* If the client has no timeout, or if the server not ready yet, and we
* know for sure that it can expire, then it's cleaner to disable the
* timeout on the client side so that too low values cannot make the
else { /* CL_STCLOSE: nothing to do */
if ((global.mode & MODE_DEBUG) && (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE))) {
int len;
- len = sprintf(trash, "%08x:%s.clicls[%04x:%04x]\n", t->uniq_id, t->be->id, (unsigned short)t->cli_fd, (unsigned short)t->srv_fd);
+ len = sprintf(trash, "%08x:%s.clicls[%04x:%04x]\n", t->uniq_id, t->be->beprm->id, (unsigned short)t->cli_fd, (unsigned short)t->srv_fd);
write(1, trash, len);
}
return 0;
return 0; /* stay in idle, waiting for data to reach the client side */
else if (c == CL_STCLOSE || c == CL_STSHUTW ||
(c == CL_STSHUTR &&
- (t->req->l == 0 || t->be->options & PR_O_ABRT_CLOSE))) { /* give up */
+ (t->req->l == 0 || t->be->beprm->options & PR_O_ABRT_CLOSE))) { /* give up */
tv_eternity(&req->cex);
if (t->pend_pos)
t->logs.t_queue = tv_diff(&t->logs.tv_accept, &now);
else if (s == SV_STCONN) { /* connection in progress */
if (c == CL_STCLOSE || c == CL_STSHUTW ||
(c == CL_STSHUTR &&
- (t->req->l == 0 || t->be->options & PR_O_ABRT_CLOSE))) { /* give up */
+ (t->req->l == 0 || t->be->beprm->options & PR_O_ABRT_CLOSE))) { /* give up */
tv_eternity(&req->cex);
fd_delete(t->srv_fd);
if (t->srv)
if (srv_count_retry_down(t, conn_err))
return 1;
- if (t->srv && t->conn_retries == 0 && t->be->options & PR_O_REDISP) {
+ if (t->srv && t->conn_retries == 0 && t->be->beprm->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))
+ if (may_dequeue_tasks(t->srv, t->be->beprm))
task_wakeup(&rq, t->srv->queue_mgt);
if (t->srv)
t->srv->failed_conns++;
- t->be->failed_conns++;
+ t->be->beprm->failed_conns++;
t->flags &= ~(SN_DIRECT | SN_ASSIGNED | SN_ADDR_SET);
t->srv = NULL; /* it's left to the dispatcher to choose a server */
tv_eternity(&req->wex);
} else /* need the right to write */ {
MY_FD_SET(t->srv_fd, StaticWriteEvent);
- if (t->be->srvtimeout) {
- tv_delayfrom(&req->wex, &now, t->be->srvtimeout);
+ if (t->be->beprm->srvtimeout) {
+ tv_delayfrom(&req->wex, &now, t->be->beprm->srvtimeout);
/* FIXME: to prevent the server from expiring read timeouts during writes,
* we refresh it. */
rep->rex = req->wex;
tv_eternity(&req->wex);
}
- if (t->be->mode == PR_MODE_TCP) { /* let's allow immediate data connection in this case */
+ if (t->be->beprm->mode == PR_MODE_TCP) { /* let's allow immediate data connection in this case */
MY_FD_SET(t->srv_fd, StaticReadEvent);
- if (t->be->srvtimeout)
- tv_delayfrom(&rep->rex, &now, t->be->srvtimeout);
+ if (t->be->beprm->srvtimeout)
+ tv_delayfrom(&rep->rex, &now, t->be->beprm->srvtimeout);
else
tv_eternity(&rep->rex);
if (t->flags & SN_CACHEABLE) {
if ((t->flags & SN_CACHE_COOK) &&
(t->flags & SN_SCK_ANY) &&
- (t->be->options & PR_O_CHK_CACHE)) {
+ (t->be->beprm->options & PR_O_CHK_CACHE)) {
/* we're in presence of a cacheable response containing
* a set-cookie header. We'll block it as requested by
if (!(t->flags & SN_FINST_MASK))
t->flags |= SN_FINST_H;
- Alert("Blocking cacheable cookie in response from instance %s, server %s.\n", t->be->id, t->srv->id);
- send_log(t->be, LOG_ALERT, "Blocking cacheable cookie in response from instance %s, server %s.\n", t->be->id, t->srv->id);
+ Alert("Blocking cacheable cookie in response from instance %s, server %s.\n", t->be->beprm->id, t->srv->id);
+ send_log(t->be, LOG_ALERT, "Blocking cacheable cookie in response from instance %s, server %s.\n", t->be->beprm->id, t->srv->id);
/* 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))
+ if (may_dequeue_tasks(t->srv, t->be->beprm))
task_wakeup(&rq, t->srv->queue_mgt);
return 1;
/* 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))
+ if (may_dequeue_tasks(t->srv, t->be->beprm))
task_wakeup(&rq, t->srv->queue_mgt);
return 1;
/* we'll have something else to do here : add new headers ... */
- if ((t->srv) && !(t->flags & SN_DIRECT) && (t->be->options & PR_O_COOK_INS) &&
- (!(t->be->options & PR_O_COOK_POST) || (t->hreq.meth == HTTP_METH_POST))) {
+ if ((t->srv) && !(t->flags & SN_DIRECT) && (t->be->beprm->options & PR_O_COOK_INS) &&
+ (!(t->be->beprm->options & PR_O_COOK_POST) || (t->hreq.meth == HTTP_METH_POST))) {
/* the server is known, it's not the one the client requested, we have to
* insert a set-cookie here, except if we want to insert only on POST
* requests and this one isn't. Note that servers which don't have cookies
* (eg: some backup servers) will return a full cookie removal request.
*/
len = sprintf(trash, "Set-Cookie: %s=%s; path=/\r\n",
- t->be->cookie_name,
+ t->be->beprm->cookie_name,
t->srv->cookie ? t->srv->cookie : "; Expires=Thu, 01-Jan-1970 00:00:01 GMT");
t->flags |= SN_SCK_INSERTED;
* Some caches understand the correct form: 'no-cache="set-cookie"', but
* others don't (eg: apache <= 1.3.26). So we use 'private' instead.
*/
- if (t->be->options & PR_O_COOK_NOC)
+ if (t->be->beprm->options & PR_O_COOK_NOC)
//len += sprintf(newhdr + len, "Cache-control: no-cache=\"set-cookie\"\r\n");
len += sprintf(trash + len, "Cache-control: private\r\n");
}
/* headers to be added */
- for (line = 0; line < t->fi->nb_rspadd; line++) {
- len = sprintf(trash, "%s\r\n", t->fi->rsp_add[line]);
+ /* FIXME: we should add headers from BE then from FE */
+ for (line = 0; line < t->be->fiprm->nb_rspadd; line++) {
+ len = sprintf(trash, "%s\r\n", t->be->fiprm->rsp_add[line]);
buffer_replace2(rep, rep->h, rep->h, trash, len);
}
* we close the server's outgoing connection right now.
*/
if ((req->l == 0) &&
- (c == CL_STSHUTR || c == CL_STCLOSE || t->be->options & PR_O_FORCE_CLO)) {
+ (c == CL_STSHUTR || c == CL_STCLOSE || t->be->beprm->options & PR_O_FORCE_CLO)) {
MY_FD_CLR(t->srv_fd, StaticWriteEvent);
tv_eternity(&req->wex);
/* We must ensure that the read part is still alive when switching
* to shutw */
MY_FD_SET(t->srv_fd, StaticReadEvent);
- if (t->be->srvtimeout)
- tv_delayfrom(&rep->rex, &now, t->be->srvtimeout);
+ if (t->be->beprm->srvtimeout)
+ tv_delayfrom(&rep->rex, &now, t->be->beprm->srvtimeout);
shutdown(t->srv_fd, SHUT_WR);
t->srv_state = SV_STSHUTW;
* unless the response includes appropriate
* Cache-Control or Expires header fields."
*/
- if (!(t->hreq.meth == HTTP_METH_POST) && (t->be->options & PR_O_CHK_CACHE))
+ if (!(t->hreq.meth == HTTP_METH_POST) && (t->be->beprm->options & PR_O_CHK_CACHE))
t->flags |= SN_CACHEABLE | SN_CACHE_COOK;
break;
default:
else if (t->logs.logwait & LW_RSPHDR) {
struct cap_hdr *h;
int len;
- for (h = t->fi->rsp_cap; h; h = h->next) {
+ for (h = t->fe->fiprm->rsp_cap; h; h = h->next) {
if ((h->namelen + 2 <= ptr - rep->h) &&
(rep->h[h->namelen] == ':') &&
(strncasecmp(rep->h, h->name, h->namelen) == 0)) {
}
/* try headers regexps */
- if (!delete_header && t->fi->rsp_exp != NULL
+ if (!delete_header && t->be->fiprm->rsp_exp != NULL
&& !(t->flags & SN_SVDENY)) {
struct hdr_exp *exp;
char term;
term = *ptr;
*ptr = '\0';
- exp = t->fi->rsp_exp;
+ exp = t->be->fiprm->rsp_exp;
do {
if (regexec(exp->preg, rep->h, MAX_MATCH, pmatch, 0) == 0) {
switch (exp->action) {
/* check for server cookies */
if (!delete_header /*&& (t->proxy->options & PR_O_COOK_ANY)*/
- && (t->be->cookie_name != NULL || t->fi->capture_name != NULL || t->be->appsession_name !=NULL)
+ && (t->be->beprm->cookie_name != NULL ||
+ t->be->fiprm->capture_name != NULL ||
+ t->be->beprm->appsession_name !=NULL)
&& (strncasecmp(rep->h, "Set-Cookie: ", 12) == 0)) {
char *p1, *p2, *p3, *p4;
*/
/* first, let's see if we want to capture it */
- if (t->fi->capture_name != NULL &&
+ if (t->be->fiprm->capture_name != NULL &&
t->logs.srv_cookie == NULL &&
- (p4 - p1 >= t->fi->capture_namelen) &&
- memcmp(p1, t->fi->capture_name, t->fi->capture_namelen) == 0) {
+ (p4 - p1 >= t->be->fiprm->capture_namelen) &&
+ memcmp(p1, t->be->fiprm->capture_name, t->be->fiprm->capture_namelen) == 0) {
int log_len = p4 - p1;
if ((t->logs.srv_cookie = pool_alloc(capture)) == NULL) {
Alert("HTTP logging : out of memory.\n");
}
- if (log_len > t->fi->capture_len)
- log_len = t->fi->capture_len;
+ if (log_len > t->be->fiprm->capture_len)
+ log_len = t->be->fiprm->capture_len;
memcpy(t->logs.srv_cookie, p1, log_len);
t->logs.srv_cookie[log_len] = 0;
}
- if ((p2 - p1 == t->be->cookie_len) && (t->be->cookie_name != NULL) &&
- (memcmp(p1, t->be->cookie_name, p2 - p1) == 0)) {
+ if ((p2 - p1 == t->be->beprm->cookie_len) && (t->be->beprm->cookie_name != NULL) &&
+ (memcmp(p1, t->be->beprm->cookie_name, p2 - p1) == 0)) {
/* Cool... it's the right one */
t->flags |= SN_SCK_SEEN;
* this occurrence because we'll insert another one later.
* We'll delete it too if the "indirect" option is set and we're in
* a direct access. */
- if (((t->srv) && (t->be->options & PR_O_COOK_INS)) ||
- ((t->flags & SN_DIRECT) && (t->be->options & PR_O_COOK_IND))) {
+ if (((t->srv) && (t->be->beprm->options & PR_O_COOK_INS)) ||
+ ((t->flags & SN_DIRECT) && (t->be->beprm->options & PR_O_COOK_IND))) {
/* this header must be deleted */
delete_header = 1;
t->flags |= SN_SCK_DELETED;
}
- else if ((t->srv) && (t->be->options & PR_O_COOK_RW)) {
+ else if ((t->srv) && (t->be->beprm->options & PR_O_COOK_RW)) {
/* replace bytes p3->p4 with the cookie name associated
* with this server since we know it.
*/
buffer_replace2(rep, p3, p4, t->srv->cookie, t->srv->cklen);
t->flags |= SN_SCK_INSERTED | SN_SCK_DELETED;
}
- else if ((t->srv) && (t->be->options & PR_O_COOK_PFX)) {
+ else if ((t->srv) && (t->be->beprm->options & PR_O_COOK_PFX)) {
/* insert the cookie name associated with this server
* before existing cookie, and insert a delimitor between them..
*/
}
/* first, let's see if the cookie is our appcookie*/
- if ((t->be->appsession_name != NULL) &&
- (memcmp(p1, t->be->appsession_name, p2 - p1) == 0)) {
+ if ((t->be->beprm->appsession_name != NULL) &&
+ (memcmp(p1, t->be->beprm->appsession_name, p2 - p1) == 0)) {
/* Cool... it's the right one */
Alert("Not enought Memory process_srv():asession->sessid:malloc().\n");
send_log(t->be, LOG_ALERT, "Not enought Memory process_srv():asession->sessid:malloc().\n");
}
- memcpy(asession_temp->sessid, p3, t->be->appsession_len);
- asession_temp->sessid[t->be->appsession_len] = 0;
+ memcpy(asession_temp->sessid, p3, t->be->beprm->appsession_len);
+ asession_temp->sessid[t->be->beprm->appsession_len] = 0;
asession_temp->serverid = NULL;
/* only do insert, if lookup fails */
}
asession_temp->sessid = local_asession.sessid;
asession_temp->serverid = local_asession.serverid;
- chtbl_insert(&(t->be->htbl_proxy), (void *) asession_temp);
+ chtbl_insert(&(t->be->beprm->htbl_proxy), (void *) asession_temp);
}/* end if (chtbl_lookup()) */
else {
/* free wasted memory */
if (asession_temp->serverid[0] == '\0')
memcpy(asession_temp->serverid,t->srv->id,server_id_len);
- tv_delayfrom(&asession_temp->expire, &now, t->be->appsession_timeout);
+ tv_delayfrom(&asession_temp->expire, &now, t->be->beprm->appsession_timeout);
#if defined(DEBUG_HASH)
- print_table(&(t->be->htbl_proxy));
+ print_table(&(t->be->beprm->htbl_proxy));
#endif
break;
}/* end if ((t->proxy->appsession_name != NULL) ... */
/* check for any set-cookie in case we check for cacheability */
if (!delete_header && !(t->flags & SN_SCK_ANY) &&
- (t->be->options & PR_O_CHK_CACHE) &&
+ (t->be->beprm->options & PR_O_CHK_CACHE) &&
(strncasecmp(rep->h, "Set-Cookie: ", 12) == 0)) {
t->flags |= SN_SCK_ANY;
}
* rep->l == rlim-data
*/
MY_FD_SET(t->srv_fd, StaticReadEvent);
- if (t->be->srvtimeout)
- tv_delayfrom(&rep->rex, &now, t->be->srvtimeout);
+ if (t->be->beprm->srvtimeout)
+ tv_delayfrom(&rep->rex, &now, t->be->beprm->srvtimeout);
else
tv_eternity(&rep->rex);
}
/* 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))
+ if (may_dequeue_tasks(t->srv, t->be->beprm))
task_wakeup(&rq, t->srv->queue_mgt);
return 1;
/* 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))
+ if (may_dequeue_tasks(t->srv, t->be->beprm))
task_wakeup(&rq, t->srv->queue_mgt);
return 1;
/* We must ensure that the read part is still alive when switching
* to shutw */
MY_FD_SET(t->srv_fd, StaticReadEvent);
- if (t->be->srvtimeout)
- tv_delayfrom(&rep->rex, &now, t->be->srvtimeout);
+ if (t->be->beprm->srvtimeout)
+ tv_delayfrom(&rep->rex, &now, t->be->beprm->srvtimeout);
shutdown(t->srv_fd, SHUT_WR);
t->srv_state = SV_STSHUTW;
/* We must ensure that the read part is still alive when switching
* to shutw */
MY_FD_SET(t->srv_fd, StaticReadEvent);
- if (t->be->srvtimeout)
- tv_delayfrom(&rep->rex, &now, t->be->srvtimeout);
+ if (t->be->beprm->srvtimeout)
+ tv_delayfrom(&rep->rex, &now, t->be->beprm->srvtimeout);
/* We must ensure that the read part is still alive when switching
* to shutw */
MY_FD_SET(t->srv_fd, StaticReadEvent);
- if (t->be->srvtimeout)
- tv_delayfrom(&rep->rex, &now, t->be->srvtimeout);
+ if (t->be->beprm->srvtimeout)
+ tv_delayfrom(&rep->rex, &now, t->be->beprm->srvtimeout);
t->srv_state = SV_STSHUTW;
if (!(t->flags & SN_ERR_MASK))
else { /* client buffer not empty */
if (! MY_FD_ISSET(t->srv_fd, StaticWriteEvent)) {
MY_FD_SET(t->srv_fd, StaticWriteEvent); /* restart writing */
- if (t->be->srvtimeout) {
- tv_delayfrom(&req->wex, &now, t->be->srvtimeout);
+ if (t->be->beprm->srvtimeout) {
+ tv_delayfrom(&req->wex, &now, t->be->beprm->srvtimeout);
/* FIXME: to prevent the server from expiring read timeouts during writes,
* we refresh it. */
rep->rex = req->wex;
/* 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))
+ if (may_dequeue_tasks(t->srv, t->be->beprm))
task_wakeup(&rq, t->srv->queue_mgt);
return 1;
/* We must ensure that the read part is still alive when switching
* to shutw */
MY_FD_SET(t->srv_fd, StaticReadEvent);
- if (t->be->srvtimeout)
- tv_delayfrom(&rep->rex, &now, t->be->srvtimeout);
+ if (t->be->beprm->srvtimeout)
+ tv_delayfrom(&rep->rex, &now, t->be->beprm->srvtimeout);
t->srv_state = SV_STSHUTW;
return 1;
/* We must ensure that the read part is still alive when switching
* to shutw */
MY_FD_SET(t->srv_fd, StaticReadEvent);
- if (t->be->srvtimeout)
- tv_delayfrom(&rep->rex, &now, t->be->srvtimeout);
+ if (t->be->beprm->srvtimeout)
+ tv_delayfrom(&rep->rex, &now, t->be->beprm->srvtimeout);
t->srv_state = SV_STSHUTW;
if (!(t->flags & SN_ERR_MASK))
t->flags |= SN_ERR_SRVTO;
else { /* buffer not empty, there are still data to be transferred */
if (! MY_FD_ISSET(t->srv_fd, StaticWriteEvent)) {
MY_FD_SET(t->srv_fd, StaticWriteEvent); /* restart writing */
- if (t->be->srvtimeout) {
- tv_delayfrom(&req->wex, &now, t->be->srvtimeout);
+ if (t->be->beprm->srvtimeout) {
+ tv_delayfrom(&req->wex, &now, t->be->beprm->srvtimeout);
/* FIXME: to prevent the server from expiring read timeouts during writes,
* we refresh it. */
rep->rex = req->wex;
else {
if (! MY_FD_ISSET(t->srv_fd, StaticReadEvent)) {
MY_FD_SET(t->srv_fd, StaticReadEvent);
- if (t->be->srvtimeout)
- tv_delayfrom(&rep->rex, &now, t->be->srvtimeout);
+ if (t->be->beprm->srvtimeout)
+ tv_delayfrom(&rep->rex, &now, t->be->beprm->srvtimeout);
else
tv_eternity(&rep->rex);
}
/* 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))
+ if (may_dequeue_tasks(t->srv, t->be->beprm))
task_wakeup(&rq, t->srv->queue_mgt);
return 1;
/* 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))
+ if (may_dequeue_tasks(t->srv, t->be->beprm))
task_wakeup(&rq, t->srv->queue_mgt);
return 1;
/* 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))
+ if (may_dequeue_tasks(t->srv, t->be->beprm))
task_wakeup(&rq, t->srv->queue_mgt);
return 1;
else { /* buffer not empty */
if (! MY_FD_ISSET(t->srv_fd, StaticWriteEvent)) {
MY_FD_SET(t->srv_fd, StaticWriteEvent); /* restart writing */
- if (t->be->srvtimeout) {
- tv_delayfrom(&req->wex, &now, t->be->srvtimeout);
+ if (t->be->beprm->srvtimeout) {
+ tv_delayfrom(&req->wex, &now, t->be->beprm->srvtimeout);
/* FIXME: to prevent the server from expiring read timeouts during writes,
* we refresh it. */
rep->rex = req->wex;
/* 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))
+ if (may_dequeue_tasks(t->srv, t->be->beprm))
task_wakeup(&rq, t->srv->queue_mgt);
return 1;
/* 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))
+ if (may_dequeue_tasks(t->srv, t->be->beprm))
task_wakeup(&rq, t->srv->queue_mgt);
return 1;
/* 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))
+ if (may_dequeue_tasks(t->srv, t->be->beprm))
task_wakeup(&rq, t->srv->queue_mgt);
return 1;
else {
if (! MY_FD_ISSET(t->srv_fd, StaticReadEvent)) {
MY_FD_SET(t->srv_fd, StaticReadEvent);
- if (t->be->srvtimeout)
- tv_delayfrom(&rep->rex, &now, t->be->srvtimeout);
+ if (t->be->beprm->srvtimeout)
+ tv_delayfrom(&rep->rex, &now, t->be->beprm->srvtimeout);
else
tv_eternity(&rep->rex);
}
else { /* SV_STCLOSE : nothing to do */
if ((global.mode & MODE_DEBUG) && (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE))) {
int len;
- len = sprintf(trash, "%08x:%s.srvcls[%04x:%04x]\n", t->uniq_id, t->be->id, (unsigned short)t->cli_fd, (unsigned short)t->srv_fd);
+ len = sprintf(trash, "%08x:%s.srvcls[%04x:%04x]\n", t->uniq_id, t->be->beprm->id, (unsigned short)t->cli_fd, (unsigned short)t->srv_fd);
write(1, trash, len);
}
return 0;
if (px->state == PR_STSTOPPED)
goto next_proxy;
- if (s->fi->uri_auth && s->fi->uri_auth->scope) {
+ if (s->be->fiprm->uri_auth && s->be->fiprm->uri_auth->scope) {
/* we have a limited scope, we have to check the proxy name */
struct stat_scope *scope;
int len;
len = strlen(px->id);
- scope = s->fi->uri_auth->scope;
+ scope = s->be->fiprm->uri_auth->scope;
while (scope) {
/* match exact proxy name */
char *cur_ptr, *cur_end, *cur_next;
int cur_idx, old_idx, abort_filt;
- if (t->be->cookie_name == NULL &&
- t->be->appsession_name ==NULL &&
- t->fi->capture_name != NULL)
+ if (t->be->beprm->cookie_name == NULL &&
+ t->be->beprm->appsession_name ==NULL &&
+ t->be->fiprm->capture_name != NULL)
return;
-
-
/* Iterate through the headers.
* we start with the start line.
*/
}
else {
/* first, let's see if we want to capture it */
- if (t->fi->capture_name != NULL &&
+ if (t->fe->fiprm->capture_name != NULL &&
t->logs.cli_cookie == NULL &&
- (p4 - p1 >= t->fi->capture_namelen) &&
- memcmp(p1, t->fi->capture_name, t->fi->capture_namelen) == 0) {
+ (p4 - p1 >= t->fe->fiprm->capture_namelen) &&
+ memcmp(p1, t->fe->fiprm->capture_name, t->fe->fiprm->capture_namelen) == 0) {
int log_len = p4 - p1;
if ((t->logs.cli_cookie = pool_alloc(capture)) == NULL) {
Alert("HTTP logging : out of memory.\n");
} else {
- if (log_len > t->fi->capture_len)
- log_len = t->fi->capture_len;
+ if (log_len > t->fe->fiprm->capture_len)
+ log_len = t->fe->fiprm->capture_len;
memcpy(t->logs.cli_cookie, p1, log_len);
t->logs.cli_cookie[log_len] = 0;
}
}
- if ((p2 - p1 == t->be->cookie_len) && (t->be->cookie_name != NULL) &&
- (memcmp(p1, t->be->cookie_name, p2 - p1) == 0)) {
+ if ((p2 - p1 == t->be->beprm->cookie_len) && (t->be->beprm->cookie_name != NULL) &&
+ (memcmp(p1, t->be->beprm->cookie_name, p2 - p1) == 0)) {
/* Cool... it's the right one */
- struct server *srv = t->be->srv;
+ struct server *srv = t->be->beprm->srv;
char *delim;
/* if we're in cookie prefix mode, we'll search the delimitor so that we
* +------------------------> cur_ptr
*/
- if (t->be->options & PR_O_COOK_PFX) {
+ if (t->be->beprm->options & PR_O_COOK_PFX) {
for (delim = p3; delim < p4; delim++)
if (*delim == COOKIE_DELIM)
break;
while (srv) {
if ((srv->cklen == delim - p3) && !memcmp(p3, srv->cookie, delim - p3)) {
- if (srv->state & SRV_RUNNING || t->be->options & PR_O_PERSIST) {
+ if (srv->state & SRV_RUNNING || t->be->beprm->options & PR_O_PERSIST) {
/* we found the server and it's usable */
t->flags &= ~SN_CK_MASK;
t->flags |= SN_CK_VALID | SN_DIRECT | SN_ASSIGNED;
* application cookie so that it does not get accidentely removed later,
* if we're in cookie prefix mode
*/
- if ((t->be->options & PR_O_COOK_PFX) && (delim != p4)) {
+ if ((t->be->beprm->options & PR_O_COOK_PFX) && (delim != p4)) {
int delta; /* negative */
delta = buffer_replace2(req, p3, delim + 1, NULL, 0);
app_cookies++; /* protect the header from deletion */
}
else if (del_cookie == NULL &&
- (t->be->options & (PR_O_COOK_INS | PR_O_COOK_IND)) == (PR_O_COOK_INS | PR_O_COOK_IND)) {
+ (t->be->beprm->options & (PR_O_COOK_INS | PR_O_COOK_IND)) == (PR_O_COOK_INS | PR_O_COOK_IND)) {
del_cookie = p1;
del_colon = colon;
}
}
}
- if ((t->be->appsession_name != NULL) &&
- (memcmp(p1, t->be->appsession_name, p2 - p1) == 0)) {
+ if ((t->be->beprm->appsession_name != NULL) &&
+ (memcmp(p1, t->be->beprm->appsession_name, p2 - p1) == 0)) {
/* first, let's see if the cookie is our appcookie*/
/* Cool... it's the right one */
return;
}
- memcpy(asession_temp->sessid, p3, t->be->appsession_len);
- asession_temp->sessid[t->be->appsession_len] = 0;
+ memcpy(asession_temp->sessid, p3, t->be->beprm->appsession_len);
+ asession_temp->sessid[t->be->beprm->appsession_len] = 0;
asession_temp->serverid = NULL;
/* only do insert, if lookup fails */
- if (chtbl_lookup(&(t->be->htbl_proxy), (void *) &asession_temp) != 0) {
+ if (chtbl_lookup(&(t->be->beprm->htbl_proxy), (void *) &asession_temp) != 0) {
if ((asession_temp = pool_alloc(appsess)) == NULL) {
/* free previously allocated memory */
pool_free_to(apools.sessid, local_asession.sessid);
asession_temp->sessid = local_asession.sessid;
asession_temp->serverid = local_asession.serverid;
- chtbl_insert(&(t->be->htbl_proxy), (void *) asession_temp);
+ chtbl_insert(&(t->be->beprm->htbl_proxy), (void *) asession_temp);
} else {
/* free previously allocated memory */
pool_free_to(apools.sessid, local_asession.sessid);
if (asession_temp->serverid == NULL) {
Alert("Found Application Session without matching server.\n");
} else {
- struct server *srv = t->be->srv;
+ struct server *srv = t->be->beprm->srv;
while (srv) {
if (strcmp(srv->id, asession_temp->serverid) == 0) {
- if (srv->state & SRV_RUNNING || t->be->options & PR_O_PERSIST) {
+ if (srv->state & SRV_RUNNING || t->be->beprm->options & PR_O_PERSIST) {
/* we found the server and it's usable */
t->flags &= ~SN_CK_MASK;
t->flags |= SN_CK_VALID | SN_DIRECT | SN_ASSIGNED;
}/* end while(srv) */
}/* end else if server == NULL */
- tv_delayfrom(&asession_temp->expire, &now, t->be->appsession_timeout);
+ tv_delayfrom(&asession_temp->expire, &now, t->be->beprm->appsession_timeout);
}/* end if ((t->proxy->appsession_name != NULL) ... */
}
appsess local_asession;
char *request_line;
- if (t->be->appsession_name == NULL ||
+ if (t->be->beprm->appsession_name == NULL ||
(t->hreq.meth != HTTP_METH_GET && t->hreq.meth != HTTP_METH_POST) ||
(request_line = memchr(begin, ';', end - begin)) == NULL ||
- ((1 + t->be->appsession_name_len + 1 + t->be->appsession_len) > (end - request_line)))
+ ((1 + t->be->beprm->appsession_name_len + 1 + t->be->beprm->appsession_len) > (end - request_line)))
return;
/* skip ';' */
request_line++;
/* look if we have a jsessionid */
- if (strncasecmp(request_line, t->be->appsession_name, t->be->appsession_name_len) != 0)
+ if (strncasecmp(request_line, t->be->beprm->appsession_name, t->be->beprm->appsession_name_len) != 0)
return;
/* skip jsessionid= */
- request_line += t->be->appsession_name_len + 1;
+ request_line += t->be->beprm->appsession_name_len + 1;
/* First try if we already have an appsession */
asession_temp = &local_asession;
}
/* Copy the sessionid */
- memcpy(asession_temp->sessid, request_line, t->be->appsession_len);
- asession_temp->sessid[t->be->appsession_len] = 0;
+ memcpy(asession_temp->sessid, request_line, t->be->beprm->appsession_len);
+ asession_temp->sessid[t->be->beprm->appsession_len] = 0;
asession_temp->serverid = NULL;
/* only do insert, if lookup fails */
- if (chtbl_lookup(&(t->be->htbl_proxy), (void *)&asession_temp)) {
+ if (chtbl_lookup(&(t->be->beprm->htbl_proxy), (void *)&asession_temp)) {
if ((asession_temp = pool_alloc(appsess)) == NULL) {
/* free previously allocated memory */
pool_free_to(apools.sessid, local_asession.sessid);
}
asession_temp->sessid = local_asession.sessid;
asession_temp->serverid = local_asession.serverid;
- chtbl_insert(&(t->be->htbl_proxy), (void *) asession_temp);
+ chtbl_insert(&(t->be->beprm->htbl_proxy), (void *) asession_temp);
}
else {
/* free previously allocated memory */
pool_free_to(apools.sessid, local_asession.sessid);
}
- tv_delayfrom(&asession_temp->expire, &now, t->be->appsession_timeout);
+ tv_delayfrom(&asession_temp->expire, &now, t->be->beprm->appsession_timeout);
asession_temp->request_count++;
#if defined(DEBUG_HASH)
if (asession_temp->serverid == NULL) {
Alert("Found Application Session without matching server.\n");
} else {
- struct server *srv = t->be->srv;
+ struct server *srv = t->be->beprm->srv;
while (srv) {
if (strcmp(srv->id, asession_temp->serverid) == 0) {
- if (srv->state & SRV_RUNNING || t->be->options & PR_O_PERSIST) {
+ if (srv->state & SRV_RUNNING || t->be->beprm->options & PR_O_PERSIST) {
/* we found the server and it's usable */
t->flags &= ~SN_CK_MASK;
t->flags |= SN_CK_VALID | SN_DIRECT | SN_ASSIGNED;
* In a GET request, check if the requested URI matches the stats uri for the
* current backend, and if an authorization has been passed and is valid.
*
- * It is assumed that the request is a GET and that the t->be->uri_auth field
+ * It is assumed that the request is a GET and that the t->be->fiprm->uri_auth field
* is valid. An HTTP/401 response may be sent, or produce_content() can be
* called to start sending data.
*