Mercurial > hg > nginx
comparison src/http/modules/ngx_http_limit_zone_module.c @ 1011:19118c44303f
test length of variable and number of connections
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 11 Jan 2007 16:50:06 +0000 |
parents | cdde2d4ea5d8 |
children | 11ffb8e4753f |
comparison
equal
deleted
inserted
replaced
1010:d1792e17a559 | 1011:19118c44303f |
---|---|
129 | 129 |
130 if (vv == NULL || vv->not_found) { | 130 if (vv == NULL || vv->not_found) { |
131 return NGX_DECLINED; | 131 return NGX_DECLINED; |
132 } | 132 } |
133 | 133 |
134 len = vv->len; | |
135 | |
136 if (len == 0) { | |
137 return NGX_DECLINED; | |
138 } | |
139 | |
140 if (len > 255) { | |
141 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
142 "the value of the \"%V\" variable " | |
143 "is more than 255 bytes: \"%V\"", | |
144 &ctx->var, vv); | |
145 return NGX_DECLINED; | |
146 } | |
147 | |
134 r->main->limit_zone_set = 1; | 148 r->main->limit_zone_set = 1; |
135 | |
136 len = vv->len; | |
137 | 149 |
138 hash = ngx_crc32_short(vv->data, len); | 150 hash = ngx_crc32_short(vv->data, len); |
139 | 151 |
140 cln = ngx_pool_cleanup_add(r->pool, sizeof(ngx_http_limit_zone_cleanup_t)); | 152 cln = ngx_pool_cleanup_add(r->pool, sizeof(ngx_http_limit_zone_cleanup_t)); |
141 if (cln == NULL) { | 153 if (cln == NULL) { |
417 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 429 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
418 "invalid number of connections \"%V\"", &value[2]); | 430 "invalid number of connections \"%V\"", &value[2]); |
419 return NGX_CONF_ERROR; | 431 return NGX_CONF_ERROR; |
420 } | 432 } |
421 | 433 |
434 if (n > 65535) { | |
435 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
436 "connection limit must be less 65536"); | |
437 return NGX_CONF_ERROR; | |
438 } | |
439 | |
422 lzcf->conn = n; | 440 lzcf->conn = n; |
423 | 441 |
424 return NGX_CONF_OK; | 442 return NGX_CONF_OK; |
425 } | 443 } |
426 | 444 |