summaryrefslogtreecommitdiffstats
path: root/usr.sbin/nginx/src/http/modules/ngx_http_limit_req_module.c
diff options
context:
space:
mode:
authorrobert <robert@openbsd.org>2013-06-01 16:12:54 +0000
committerrobert <robert@openbsd.org>2013-06-01 16:12:54 +0000
commitd8dc9a5250771aed5ee92cbc434097082ef103f1 (patch)
tree1d1294b5132ddb61207c9fcb594f00810c3fdb69 /usr.sbin/nginx/src/http/modules/ngx_http_limit_req_module.c
parentAs found by kurt, there's a twisty race between exit1 and fork1 (diff)
downloadwireguard-openbsd-d8dc9a5250771aed5ee92cbc434097082ef103f1.tar.xz
wireguard-openbsd-d8dc9a5250771aed5ee92cbc434097082ef103f1.zip
update to nginx-1.4.1 and enable the SPDY module by default
Diffstat (limited to 'usr.sbin/nginx/src/http/modules/ngx_http_limit_req_module.c')
-rw-r--r--usr.sbin/nginx/src/http/modules/ngx_http_limit_req_module.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/usr.sbin/nginx/src/http/modules/ngx_http_limit_req_module.c b/usr.sbin/nginx/src/http/modules/ngx_http_limit_req_module.c
index 31a8b987a65..90434c956a6 100644
--- a/usr.sbin/nginx/src/http/modules/ngx_http_limit_req_module.c
+++ b/usr.sbin/nginx/src/http/modules/ngx_http_limit_req_module.c
@@ -53,6 +53,7 @@ typedef struct {
ngx_array_t limits;
ngx_uint_t limit_log_level;
ngx_uint_t delay_log_level;
+ ngx_uint_t status_code;
} ngx_http_limit_req_conf_t;
@@ -84,6 +85,11 @@ static ngx_conf_enum_t ngx_http_limit_req_log_levels[] = {
};
+static ngx_conf_num_bounds_t ngx_http_limit_req_status_bounds = {
+ ngx_conf_check_num_bounds, 400, 599
+};
+
+
static ngx_command_t ngx_http_limit_req_commands[] = {
{ ngx_string("limit_req_zone"),
@@ -107,6 +113,13 @@ static ngx_command_t ngx_http_limit_req_commands[] = {
offsetof(ngx_http_limit_req_conf_t, limit_log_level),
&ngx_http_limit_req_log_levels },
+ { ngx_string("limit_req_status"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_num_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_limit_req_conf_t, status_code),
+ &ngx_http_limit_req_status_bounds },
+
ngx_null_command
};
@@ -245,7 +258,7 @@ ngx_http_limit_req_handler(ngx_http_request_t *r)
ctx->node = NULL;
}
- return NGX_HTTP_SERVICE_UNAVAILABLE;
+ return lrcf->status_code;
}
/* rc == NGX_AGAIN || rc == NGX_OK */
@@ -682,6 +695,7 @@ ngx_http_limit_req_create_conf(ngx_conf_t *cf)
*/
conf->limit_log_level = NGX_CONF_UNSET_UINT;
+ conf->status_code = NGX_CONF_UNSET_UINT;
return conf;
}
@@ -703,6 +717,9 @@ ngx_http_limit_req_merge_conf(ngx_conf_t *cf, void *parent, void *child)
conf->delay_log_level = (conf->limit_log_level == NGX_LOG_INFO) ?
NGX_LOG_INFO : conf->limit_log_level + 1;
+ ngx_conf_merge_uint_value(conf->status_code, prev->status_code,
+ NGX_HTTP_SERVICE_UNAVAILABLE);
+
return NGX_CONF_OK;
}
@@ -778,7 +795,7 @@ ngx_http_limit_req_zone(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
}
rate = ngx_atoi(value[i].data + 5, len - 5);
- if (rate <= NGX_ERROR) {
+ if (rate <= 0) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"invalid rate \"%V\"", &value[i]);
return NGX_CONF_ERROR;