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 <w.dauchy@criteo.com>
This commit is contained in:
William Dauchy 2020-01-16 01:34:27 +01:00 committed by Willy Tarreau
parent ac8147446c
commit bb9da0b8e2
1 changed files with 4 additions and 6 deletions

View File

@ -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) {