mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-28 06:11:32 +01:00
MINOR: backend: move url_param_name/len to lbprm.arg_str/len
This one is exclusively used by LB parameters, when using URL param hashing. Let's move it to the lbprm struct under a more generic name.
This commit is contained in:
parent
6c30be52da
commit
4c03d1c9b6
@ -144,6 +144,8 @@ struct lbprm {
|
||||
int tot_used; /* total number of servers used for LB */
|
||||
int wmult; /* ratio between user weight and effective weight */
|
||||
int wdiv; /* ratio between effective weight and user weight */
|
||||
char *arg_str; /* name of the URL parameter used for hashing */
|
||||
int arg_len; /* strlen(arg_str), computed only once */
|
||||
struct server *fbck; /* first backup server when !PR_O_USE_ALL_BK, or NULL */
|
||||
struct lb_map map; /* LB parameters for map-based algorithms */
|
||||
struct lb_fwrr fwrr;
|
||||
|
||||
@ -320,8 +320,6 @@ struct proxy {
|
||||
unsigned int cookie_maxlife; /* max life time for this cookie */
|
||||
char *rdp_cookie_name; /* name of the RDP cookie to look for */
|
||||
int rdp_cookie_len; /* strlen(rdp_cookie_name), computed only once */
|
||||
char *url_param_name; /* name of the URL parameter used for hashing */
|
||||
int url_param_len; /* strlen(url_param_name), computed only once */
|
||||
int uri_len_limit; /* character limit for uri balancing algorithm */
|
||||
int uri_dirs_depth1; /* directories+1 (slashes) limit for uri balancing algorithm */
|
||||
int uri_whole; /* if != 0, calculates the hash from the whole uri. Still honors the len_limit and dirs_depth1 */
|
||||
|
||||
@ -271,13 +271,13 @@ static struct server *get_server_ph(struct proxy *px, const char *uri, int uri_l
|
||||
p++;
|
||||
|
||||
uri_len -= (p - uri);
|
||||
plen = px->url_param_len;
|
||||
plen = px->lbprm.arg_len;
|
||||
params = p;
|
||||
|
||||
while (uri_len > plen) {
|
||||
/* Look for the parameter name followed by an equal symbol */
|
||||
if (params[plen] == '=') {
|
||||
if (memcmp(params, px->url_param_name, plen) == 0) {
|
||||
if (memcmp(params, px->lbprm.arg_str, plen) == 0) {
|
||||
/* OK, we have the parameter here at <params>, and
|
||||
* the value after the equal sign, at <p>
|
||||
* skip the equal symbol
|
||||
@ -322,7 +322,7 @@ static struct server *get_server_ph_post(struct stream *s, const struct server *
|
||||
struct channel *req = &s->req;
|
||||
struct http_msg *msg = &txn->req;
|
||||
struct proxy *px = s->be;
|
||||
unsigned int plen = px->url_param_len;
|
||||
unsigned int plen = px->lbprm.arg_len;
|
||||
unsigned long len = http_body_bytes(msg);
|
||||
const char *params = c_ptr(req, -http_data_rewind(msg));
|
||||
const char *p = params;
|
||||
@ -340,7 +340,7 @@ static struct server *get_server_ph_post(struct stream *s, const struct server *
|
||||
while (len > plen) {
|
||||
/* Look for the parameter name followed by an equal symbol */
|
||||
if (params[plen] == '=') {
|
||||
if (memcmp(params, px->url_param_name, plen) == 0) {
|
||||
if (memcmp(params, px->lbprm.arg_str, plen) == 0) {
|
||||
/* OK, we have the parameter here at <params>, and
|
||||
* the value after the equal sign, at <p>
|
||||
* skip the equal symbol
|
||||
@ -1775,9 +1775,9 @@ int backend_parse_balance(const char **args, char **err, struct proxy *curproxy)
|
||||
curproxy->lbprm.algo &= ~BE_LB_ALGO;
|
||||
curproxy->lbprm.algo |= BE_LB_ALGO_PH;
|
||||
|
||||
free(curproxy->url_param_name);
|
||||
curproxy->url_param_name = strdup(args[1]);
|
||||
curproxy->url_param_len = strlen(args[1]);
|
||||
free(curproxy->lbprm.arg_str);
|
||||
curproxy->lbprm.arg_str = strdup(args[1]);
|
||||
curproxy->lbprm.arg_len = strlen(args[1]);
|
||||
if (*args[2]) {
|
||||
if (strcmp(args[2], "check_post")) {
|
||||
memprintf(err, "%s only accepts 'check_post' modifier (got '%s').", args[0], args[2]);
|
||||
|
||||
@ -467,9 +467,9 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
||||
curproxy->rdp_cookie_name = strdup(defproxy.rdp_cookie_name);
|
||||
curproxy->rdp_cookie_len = defproxy.rdp_cookie_len;
|
||||
|
||||
if (defproxy.url_param_name)
|
||||
curproxy->url_param_name = strdup(defproxy.url_param_name);
|
||||
curproxy->url_param_len = defproxy.url_param_len;
|
||||
if (defproxy.lbprm.arg_str)
|
||||
curproxy->lbprm.arg_str = strdup(defproxy.lbprm.arg_str);
|
||||
curproxy->lbprm.arg_len = defproxy.lbprm.arg_len;
|
||||
curproxy->uri_whole = defproxy.uri_whole;
|
||||
curproxy->uri_len_limit = defproxy.uri_len_limit;
|
||||
curproxy->uri_dirs_depth1 = defproxy.uri_dirs_depth1;
|
||||
@ -621,7 +621,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
||||
free(defproxy.rdp_cookie_name);
|
||||
free(defproxy.dyncookie_key);
|
||||
free(defproxy.cookie_domain);
|
||||
free(defproxy.url_param_name);
|
||||
free(defproxy.lbprm.arg_str);
|
||||
free(defproxy.hh_name);
|
||||
free(defproxy.capture_name);
|
||||
free(defproxy.monitor_uri);
|
||||
|
||||
@ -2246,7 +2246,7 @@ void deinit(void)
|
||||
free(p->check_req);
|
||||
free(p->cookie_name);
|
||||
free(p->cookie_domain);
|
||||
free(p->url_param_name);
|
||||
free(p->lbprm.arg_str);
|
||||
free(p->capture_name);
|
||||
free(p->monitor_uri);
|
||||
free(p->rdp_cookie_name);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user