MINOR: backend: remap the balance uri settings to lbprm.arg_opt{1,2,3}
The algo-specific settings move from the proxy to the LB algo this way :
- uri_whole => arg_opt1
- uri_len_limit => arg_opt2
- uri_dirs_depth1 => arg_opt3
diff --git a/include/types/proxy.h b/include/types/proxy.h
index 1e4115e..765e81d 100644
--- a/include/types/proxy.h
+++ b/include/types/proxy.h
@@ -320,9 +320,6 @@
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 */
- 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 */
char *capture_name; /* beginning of the name of the cookie to capture */
int capture_namelen; /* length of the cookie name to match */
int capture_len; /* length of the string to be captured */
diff --git a/src/backend.c b/src/backend.c
index cc4eb97..6cca128 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -197,7 +197,9 @@
* ends at the question mark. Depending on the number of active/backup servers,
* it will either look for active servers, or for backup servers.
* If any server is found, it will be returned. If no valid server is found,
- * NULL is returned.
+ * NULL is returned. The lbprm.arg_opt{1,2,3} values correspond respectively to
+ * the "whole" optional argument (boolean), the "len" argument (numeric) and
+ * the "depth" argument (numeric).
*
* This code was contributed by Guillaume Dallaire, who also selected this hash
* algorithm out of a tens because it gave him the best results.
@@ -217,18 +219,18 @@
if (px->lbprm.tot_used == 1)
goto hash_done;
- if (px->uri_len_limit)
- uri_len = MIN(uri_len, px->uri_len_limit);
+ if (px->lbprm.arg_opt2) // "len"
+ uri_len = MIN(uri_len, px->lbprm.arg_opt2);
start = end = uri;
while (uri_len--) {
c = *end;
if (c == '/') {
slashes++;
- if (slashes == px->uri_dirs_depth1) /* depth+1 */
+ if (slashes == px->lbprm.arg_opt3) /* depth+1 */
break;
}
- else if (c == '?' && !px->uri_whole)
+ else if (c == '?' && !px->lbprm.arg_opt1) // "whole"
break;
end++;
}
@@ -1733,10 +1735,9 @@
curproxy->lbprm.algo &= ~BE_LB_ALGO;
curproxy->lbprm.algo |= BE_LB_ALGO_UH;
-
- curproxy->uri_whole = 0;
- curproxy->uri_len_limit = 0;
- curproxy->uri_dirs_depth1 = 0;
+ curproxy->lbprm.arg_opt1 = 0; // "whole"
+ curproxy->lbprm.arg_opt2 = 0; // "len"
+ curproxy->lbprm.arg_opt3 = 0; // "depth"
while (*args[arg]) {
if (!strcmp(args[arg], "len")) {
@@ -1744,7 +1745,7 @@
memprintf(err, "%s : '%s' expects a positive integer (got '%s').", args[0], args[arg], args[arg+1]);
return -1;
}
- curproxy->uri_len_limit = atoi(args[arg+1]);
+ curproxy->lbprm.arg_opt2 = atoi(args[arg+1]);
arg += 2;
}
else if (!strcmp(args[arg], "depth")) {
@@ -1755,11 +1756,11 @@
/* hint: we store the position of the ending '/' (depth+1) so
* that we avoid a comparison while computing the hash.
*/
- curproxy->uri_dirs_depth1 = atoi(args[arg+1]) + 1;
+ curproxy->lbprm.arg_opt3 = atoi(args[arg+1]) + 1;
arg += 2;
}
else if (!strcmp(args[arg], "whole")) {
- curproxy->uri_whole = 1;
+ curproxy->lbprm.arg_opt1 = 1;
arg += 1;
}
else {
diff --git a/src/cfgparse-listen.c b/src/cfgparse-listen.c
index cdeefd0..7514a47 100644
--- a/src/cfgparse-listen.c
+++ b/src/cfgparse-listen.c
@@ -475,10 +475,6 @@
curproxy->lbprm.arg_opt2 = defproxy.lbprm.arg_opt2;
curproxy->lbprm.arg_opt3 = defproxy.lbprm.arg_opt3;
- curproxy->uri_whole = defproxy.uri_whole;
- curproxy->uri_len_limit = defproxy.uri_len_limit;
- curproxy->uri_dirs_depth1 = defproxy.uri_dirs_depth1;
-
if (defproxy.conn_src.iface_name)
curproxy->conn_src.iface_name = strdup(defproxy.conn_src.iface_name);
curproxy->conn_src.iface_len = defproxy.conn_src.iface_len;