]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: backend: move url_param_name/len to lbprm.arg_str/len
authorWilly Tarreau <w@1wt.eu>
Mon, 14 Jan 2019 14:23:54 +0000 (15:23 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 14 Jan 2019 18:33:17 +0000 (19:33 +0100)
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.

include/types/backend.h
include/types/proxy.h
src/backend.c
src/cfgparse-listen.c
src/haproxy.c

index b36cd4112c2d6ddb72a700adf88245e47a590d90..ec1f5a9bcafd4399296b4c7f928a4fc54dbc631c 100644 (file)
@@ -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;
index 14b6046c698d4372bd88b6f7c2119c4afd85bd09..39e9940394b61304f580e73e9178c48c400bd7cd 100644 (file)
@@ -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 */
index 13543c90e481db98d5ac45807c9d125474f1f62f..9b6f316f87ddae4cd33a6f6ba9b98ef2a00a284d 100644 (file)
@@ -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]);
index 8d2c176a894817652081d190f2febc2c5d0607fe..b737ffa61c8143b0b8116193760342bb7017cbdd 100644 (file)
@@ -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);
index d47dff3e3785879caf0c84eb15f4fcd4e07a8c72..dbc2adabc88336355e47127c70e79260fc44d398 100644 (file)
@@ -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);