[MINOR] cleanup set_session_backend by using pre-computed analysers

Analyser bitmaps are now stored in the frontend and backend, and
combined at configuration time. That way, set_session_backend()
does not need to perform any protocol-specific combinations.
This commit is contained in:
Willy Tarreau 2009-08-16 22:37:44 +02:00
parent 2c9f5b130f
commit c1a2167e9d
4 changed files with 31 additions and 23 deletions

View File

@ -150,6 +150,7 @@ struct proxy {
int state; /* proxy state */
int options; /* PR_O_REDISP, PR_O_TRANSP, ... */
int options2; /* PR_O2_* */
unsigned int fe_req_ana, be_req_ana; /* bitmap of common request protocol analysers for the frontend and backend */
int mode; /* mode = PR_MODE_TCP, PR_MODE_HTTP or PR_MODE_HEALTH */
struct sockaddr_in dispatch_addr; /* the default address to connect to */
union {

View File

@ -4139,6 +4139,29 @@ int check_config_validity()
newsrv = newsrv->next;
}
if (curproxy->cap & PR_CAP_FE) {
if (curproxy->tcp_req.inspect_delay ||
!LIST_ISEMPTY(&curproxy->tcp_req.inspect_rules))
curproxy->fe_req_ana |= AN_REQ_INSPECT;
if (curproxy->mode == PR_MODE_HTTP)
curproxy->fe_req_ana |= AN_REQ_WAIT_HTTP | AN_REQ_HTTP_PROCESS_FE;
/* both TCP and HTTP must check switching rules */
curproxy->fe_req_ana |= AN_REQ_SWITCHING_RULES;
}
if (curproxy->cap & PR_CAP_BE) {
if (curproxy->mode == PR_MODE_HTTP)
curproxy->be_req_ana |= AN_REQ_WAIT_HTTP | AN_REQ_HTTP_INNER | AN_REQ_HTTP_PROCESS_BE;
/* If the backend does requires RDP cookie persistence, we have to
* enable the corresponding analyser.
*/
if (curproxy->options2 & PR_O2_RDPC_PRST)
curproxy->be_req_ana |= AN_REQ_PRST_RDP_COOKIE;
}
/* adjust this proxy's listeners */
listener = curproxy->listen;
while (listener) {
@ -4150,11 +4173,7 @@ int check_config_validity()
listener->accept = event_accept;
listener->private = curproxy;
listener->handler = process_session;
/* both TCP and HTTP must check switching rules */
listener->analysers |= AN_REQ_SWITCHING_RULES;
if (curproxy->mode == PR_MODE_HTTP)
listener->analysers |= AN_REQ_WAIT_HTTP | AN_REQ_HTTP_PROCESS_FE | AN_REQ_HTTP_INNER | AN_REQ_HTTP_PROCESS_BE;
listener->analysers |= curproxy->fe_req_ana;
/* smart accept mode is automatic in HTTP mode */
if ((curproxy->options2 & PR_O2_SMARTACC) ||
@ -4162,10 +4181,6 @@ int check_config_validity()
!(curproxy->no_options2 & PR_O2_SMARTACC)))
listener->options |= LI_O_NOQUICKACK;
if (curproxy->tcp_req.inspect_delay ||
!LIST_ISEMPTY(&curproxy->tcp_req.inspect_rules))
listener->analysers |= AN_REQ_INSPECT;
/* We want the use_backend and default_backend rules to apply */
listener = listener->next;
}

View File

@ -401,6 +401,7 @@ int event_accept(int fd) {
/* activate default analysers enabled for this listener */
s->req->analysers = l->analysers;
/* note: this should not happen anymore since there's always at least the switching rules */
if (!s->req->analysers)
buffer_write_ena(s->req); /* don't wait to establish connection */

View File

@ -667,21 +667,12 @@ int session_set_backend(struct session *s, struct proxy *be)
hdr_idx_init(&s->txn.hdr_idx);
}
/* If we're switching from TCP mode to HTTP mode, we need to
* enable several analysers on the backend.
/* We want to enable the backend-specific analysers except those which
* were already run as part of the frontend/listener. Note that it would
* be more reliable to store the list of analysers that have been run,
* but what we do here is OK for now.
*/
if (unlikely(s->fe->mode != PR_MODE_HTTP && s->be->mode == PR_MODE_HTTP)) {
/* We want to wait for a complete HTTP request and process the
* backend parts.
*/
s->req->analysers |= AN_REQ_WAIT_HTTP | AN_REQ_HTTP_PROCESS_BE | AN_REQ_HTTP_INNER;
}
/* If the backend does requires RDP cookie persistence, we have to
* enable the corresponding analyser.
*/
if (s->be->options2 & PR_O2_RDPC_PRST)
s->req->analysers |= AN_REQ_PRST_RDP_COOKIE;
s->req->analysers |= be->be_req_ana & ~(s->listener->analysers);
return 1;
}