From: William Dauchy Date: Thu, 16 Jan 2020 00:34:27 +0000 (+0100) Subject: CLEANUP: proxy: simplify proxy_parse_rate_limit proxy checks X-Git-Tag: v2.2-dev1~108 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb9da0b8e23c46caab34fe6005b66fa8065fe3ac;p=thirdparty%2Fhaproxy.git CLEANUP: proxy: simplify proxy_parse_rate_limit proxy checks rate-limits are valid for both frontend and listen, but not backend; so we can simplify this check in a similar manner as it is done in e.g max-keep-alive-queue. this should fix github issue #449 Signed-off-by: William Dauchy --- diff --git a/src/proxy.c b/src/proxy.c index 8720b2880a..aed32f94b4 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -330,7 +330,7 @@ static int proxy_parse_rate_limit(char **args, int section, struct proxy *proxy, struct proxy *defpx, const char *file, int line, char **err) { - int retval, cap; + int retval; char *res; unsigned int *tv = NULL; unsigned int *td = NULL; @@ -341,7 +341,6 @@ static int proxy_parse_rate_limit(char **args, int section, struct proxy *proxy, if (strcmp(args[1], "sessions") == 0) { tv = &proxy->fe_sps_lim; td = &defpx->fe_sps_lim; - cap = PR_CAP_FE; } else { memprintf(err, "'%s' only supports 'sessions' (got '%s')", args[0], args[1]); @@ -359,10 +358,9 @@ static int proxy_parse_rate_limit(char **args, int section, struct proxy *proxy, return -1; } - if (!(proxy->cap & cap)) { - memprintf(err, "%s %s will be ignored because %s '%s' has no %s capability", - args[0], args[1], proxy_type_str(proxy), proxy->id, - (cap & PR_CAP_BE) ? "backend" : "frontend"); + if (!(proxy->cap & PR_CAP_FE)) { + memprintf(err, "%s %s will be ignored because %s '%s' has no frontend capability", + args[0], args[1], proxy_type_str(proxy), proxy->id); retval = 1; } else if (defpx && *tv != *td) {