[PATCH] Limit conn: Added "off" parameter to the 'limit_conn' directive

Pavel V. pavel2000 at ngs.ru
Wed Feb 10 05:31:42 UTC 2016


Hi, Maxim!

Thanks for reviewing my patches.

>> +
>> +    if (ngx_strcmp(value[1].data, "off") == 0) {
>> +        if (cf->args->nelts != 2) {
>> +            return "has invalid number of arguments";
>> +        }
>> +
>> +        if (lccf->off || lccf->limits.elts) {
>> +            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
>> +                               "\"limit_conn off\" cannot be used with other "
>> +                               "\"limit_conn\" directives on the same level");
>> +            return NGX_CONF_ERROR;
>> +        }
>> +
>> +        lccf->off = 1;
>> +        return NGX_CONF_OK;
>> +    }
>> +
>> +    if (cf->args->nelts != 3) {
>> +        return "has invalid number of arguments";
>> +    }
>> +
>> +    if (lccf->off) {
>> +        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
>> +                           "\"limit_conn off\" cannot be used with other "
>> +                           "\"limit_conn\" directives on the same level");
>> +        return NGX_CONF_ERROR;
>> +    }
>> +

> This looks overcomplicated and far from what nginx normally prints 
> on similar errors at the same time.  It should be possible to do 
> this better.

Will the "'limit_conn' directive already defined with conflicting parameters"
message be  suitable in this case?
Which one should I use - ngx_conf_log_error() or
return 'already defined with conflicting parameter'?


-- 
Regards,
 Pavel                          mailto:pavel2000 at ngs.ru



More information about the nginx-devel mailing list