[MEDIUM] implement the URI hash algorithm
Guillaume Dallaire contributed the URI hashing algorithm for
use with proxy-caches. It provides the advantage of optimizing
the cache hit rate.
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 00b4908..feb7b60 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -1129,18 +1129,26 @@
if (*(args[1])) {
if (!strcmp(args[1], "roundrobin")) {
+ curproxy->options &= ~PR_O_BALANCE;
curproxy->options |= PR_O_BALANCE_RR;
}
else if (!strcmp(args[1], "source")) {
+ curproxy->options &= ~PR_O_BALANCE;
curproxy->options |= PR_O_BALANCE_SH;
}
+ else if (!strcmp(args[1], "uri")) {
+ curproxy->options &= ~PR_O_BALANCE;
+ curproxy->options |= PR_O_BALANCE_UH;
+ }
else {
- Alert("parsing [%s:%d] : '%s' only supports 'roundrobin' and 'source' options.\n", file, linenum, args[0]);
+ Alert("parsing [%s:%d] : '%s' only supports 'roundrobin', 'source' and 'uri' options.\n", file, linenum, args[0]);
return -1;
}
}
- else /* if no option is set, use round-robin by default */
+ else {/* if no option is set, use round-robin by default */
+ curproxy->options &= ~PR_O_BALANCE;
curproxy->options |= PR_O_BALANCE_RR;
+ }
}
else if (!strcmp(args[0], "server")) { /* server address */
int cur_arg;
@@ -2236,6 +2244,13 @@
Warning("parsing %s : monitor-uri will be ignored for %s '%s'.\n",
file, proxy_type_str(curproxy), curproxy->id);
}
+ if (curproxy->options & PR_O_BALANCE_UH) {
+ curproxy->options &= ~PR_O_BALANCE;
+ curproxy->options |= PR_O_BALANCE_RR;
+
+ Warning("parsing %s : URI hash will be ignored for %s '%s'. Falling back to round robin.\n",
+ file, proxy_type_str(curproxy), curproxy->id);
+ }
}
else if (curproxy->mode == PR_MODE_HTTP) { /* HTTP PROXY */
if ((curproxy->cookie_name != NULL) && ((newsrv = curproxy->srv) == NULL)) {