mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-17 02:56:51 +00:00
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:
parent
ac8147446c
commit
bb9da0b8e2
10
src/proxy.c
10
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,
|
struct proxy *defpx, const char *file, int line,
|
||||||
char **err)
|
char **err)
|
||||||
{
|
{
|
||||||
int retval, cap;
|
int retval;
|
||||||
char *res;
|
char *res;
|
||||||
unsigned int *tv = NULL;
|
unsigned int *tv = NULL;
|
||||||
unsigned int *td = 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) {
|
if (strcmp(args[1], "sessions") == 0) {
|
||||||
tv = &proxy->fe_sps_lim;
|
tv = &proxy->fe_sps_lim;
|
||||||
td = &defpx->fe_sps_lim;
|
td = &defpx->fe_sps_lim;
|
||||||
cap = PR_CAP_FE;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
memprintf(err, "'%s' only supports 'sessions' (got '%s')", args[0], args[1]);
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(proxy->cap & cap)) {
|
if (!(proxy->cap & PR_CAP_FE)) {
|
||||||
memprintf(err, "%s %s will be ignored because %s '%s' has no %s capability",
|
memprintf(err, "%s %s will be ignored because %s '%s' has no frontend capability",
|
||||||
args[0], args[1], proxy_type_str(proxy), proxy->id,
|
args[0], args[1], proxy_type_str(proxy), proxy->id);
|
||||||
(cap & PR_CAP_BE) ? "backend" : "frontend");
|
|
||||||
retval = 1;
|
retval = 1;
|
||||||
}
|
}
|
||||||
else if (defpx && *tv != *td) {
|
else if (defpx && *tv != *td) {
|
||||||
|
Loading…
Reference in New Issue
Block a user