]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: proxy: simplify proxy_parse_rate_limit proxy checks
authorWilliam Dauchy <w.dauchy@criteo.com>
Thu, 16 Jan 2020 00:34:27 +0000 (01:34 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 16 Jan 2020 06:04:05 +0000 (07:04 +0100)
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>
src/proxy.c

index 8720b2880a330dd582d96314649d169fe889c401..aed32f94b4c380eea6ec5c95cb08c1dd47d7e280 100644 (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) {