summaryrefslogtreecommitdiff
path: root/src/http
diff options
context:
space:
mode:
Diffstat (limited to 'src/http')
-rw-r--r--src/http/modules/ngx_http_access_module.c1
-rw-r--r--src/http/modules/ngx_http_addition_filter_module.c1
-rw-r--r--src/http/modules/ngx_http_auth_basic_module.c1
-rw-r--r--src/http/modules/ngx_http_autoindex_module.c1
-rw-r--r--src/http/modules/ngx_http_browser_module.c1
-rw-r--r--src/http/modules/ngx_http_charset_filter_module.c1
-rw-r--r--src/http/modules/ngx_http_chunked_filter_module.c1
-rw-r--r--src/http/modules/ngx_http_dav_module.c1
-rw-r--r--src/http/modules/ngx_http_degradation_module.c1
-rw-r--r--src/http/modules/ngx_http_empty_gif_module.c1
-rw-r--r--src/http/modules/ngx_http_fastcgi_module.c1
-rw-r--r--src/http/modules/ngx_http_flv_module.c1
-rw-r--r--src/http/modules/ngx_http_geo_module.c1
-rw-r--r--src/http/modules/ngx_http_geoip_module.c1
-rw-r--r--src/http/modules/ngx_http_gzip_filter_module.c1
-rw-r--r--src/http/modules/ngx_http_gzip_static_module.c1
-rw-r--r--src/http/modules/ngx_http_headers_filter_module.c1
-rw-r--r--src/http/modules/ngx_http_image_filter_module.c1
-rw-r--r--src/http/modules/ngx_http_index_module.c1
-rw-r--r--src/http/modules/ngx_http_limit_conn_module.c1
-rw-r--r--src/http/modules/ngx_http_limit_req_module.c423
-rw-r--r--src/http/modules/ngx_http_log_module.c1
-rw-r--r--src/http/modules/ngx_http_map_module.c1
-rw-r--r--src/http/modules/ngx_http_memcached_module.c1
-rw-r--r--src/http/modules/ngx_http_mp4_module.c1
-rw-r--r--src/http/modules/ngx_http_not_modified_filter_module.c1
-rw-r--r--src/http/modules/ngx_http_proxy_module.c3
-rw-r--r--src/http/modules/ngx_http_random_index_module.c1
-rw-r--r--src/http/modules/ngx_http_range_filter_module.c1
-rw-r--r--src/http/modules/ngx_http_realip_module.c1
-rw-r--r--src/http/modules/ngx_http_referer_module.c1
-rw-r--r--src/http/modules/ngx_http_rewrite_module.c1
-rw-r--r--src/http/modules/ngx_http_scgi_module.c1
-rw-r--r--src/http/modules/ngx_http_secure_link_module.c1
-rw-r--r--src/http/modules/ngx_http_split_clients_module.c1
-rw-r--r--src/http/modules/ngx_http_ssi_filter_module.c1
-rw-r--r--src/http/modules/ngx_http_ssi_filter_module.h1
-rw-r--r--src/http/modules/ngx_http_ssl_module.c1
-rw-r--r--src/http/modules/ngx_http_ssl_module.h1
-rw-r--r--src/http/modules/ngx_http_static_module.c1
-rw-r--r--src/http/modules/ngx_http_stub_status_module.c1
-rw-r--r--src/http/modules/ngx_http_sub_filter_module.c1
-rw-r--r--src/http/modules/ngx_http_upstream_ip_hash_module.c1
-rw-r--r--src/http/modules/ngx_http_upstream_keepalive_module.c1
-rw-r--r--src/http/modules/ngx_http_userid_filter_module.c1
-rw-r--r--src/http/modules/ngx_http_uwsgi_module.c1
-rw-r--r--src/http/modules/ngx_http_xslt_filter_module.c1
-rw-r--r--src/http/modules/perl/Makefile.PL1
-rw-r--r--src/http/modules/perl/nginx.pm3
-rw-r--r--src/http/modules/perl/nginx.xs1
-rw-r--r--src/http/modules/perl/ngx_http_perl_module.c1
-rw-r--r--src/http/modules/perl/ngx_http_perl_module.h1
-rw-r--r--src/http/ngx_http.c1
-rw-r--r--src/http/ngx_http.h1
-rw-r--r--src/http/ngx_http_busy_lock.c1
-rw-r--r--src/http/ngx_http_busy_lock.h1
-rw-r--r--src/http/ngx_http_cache.h1
-rw-r--r--src/http/ngx_http_config.h1
-rw-r--r--src/http/ngx_http_copy_filter_module.c3
-rw-r--r--src/http/ngx_http_core_module.c1
-rw-r--r--src/http/ngx_http_core_module.h1
-rw-r--r--src/http/ngx_http_file_cache.c1
-rw-r--r--src/http/ngx_http_header_filter_module.c1
-rw-r--r--src/http/ngx_http_parse.c1
-rw-r--r--src/http/ngx_http_parse_time.c1
-rw-r--r--src/http/ngx_http_postpone_filter_module.c1
-rw-r--r--src/http/ngx_http_request.c1
-rw-r--r--src/http/ngx_http_request.h1
-rw-r--r--src/http/ngx_http_request_body.c1
-rw-r--r--src/http/ngx_http_script.c1
-rw-r--r--src/http/ngx_http_script.h1
-rw-r--r--src/http/ngx_http_special_response.c1
-rw-r--r--src/http/ngx_http_upstream.c1
-rw-r--r--src/http/ngx_http_upstream.h1
-rw-r--r--src/http/ngx_http_upstream_round_robin.c1
-rw-r--r--src/http/ngx_http_upstream_round_robin.h1
-rw-r--r--src/http/ngx_http_variables.c1
-rw-r--r--src/http/ngx_http_variables.h1
-rw-r--r--src/http/ngx_http_write_filter_module.c1
79 files changed, 372 insertions, 135 deletions
diff --git a/src/http/modules/ngx_http_access_module.c b/src/http/modules/ngx_http_access_module.c
index a28ebf7b7..84a75d777 100644
--- a/src/http/modules/ngx_http_access_module.c
+++ b/src/http/modules/ngx_http_access_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_addition_filter_module.c b/src/http/modules/ngx_http_addition_filter_module.c
index 9b22a0a12..24747c564 100644
--- a/src/http/modules/ngx_http_addition_filter_module.c
+++ b/src/http/modules/ngx_http_addition_filter_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_auth_basic_module.c b/src/http/modules/ngx_http_auth_basic_module.c
index 45168de84..ec3b1cf95 100644
--- a/src/http/modules/ngx_http_auth_basic_module.c
+++ b/src/http/modules/ngx_http_auth_basic_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_autoindex_module.c b/src/http/modules/ngx_http_autoindex_module.c
index bd7388126..9b54d0cf9 100644
--- a/src/http/modules/ngx_http_autoindex_module.c
+++ b/src/http/modules/ngx_http_autoindex_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_browser_module.c b/src/http/modules/ngx_http_browser_module.c
index d400fec7f..13a714538 100644
--- a/src/http/modules/ngx_http_browser_module.c
+++ b/src/http/modules/ngx_http_browser_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_charset_filter_module.c b/src/http/modules/ngx_http_charset_filter_module.c
index a6f9afcae..27a00d09a 100644
--- a/src/http/modules/ngx_http_charset_filter_module.c
+++ b/src/http/modules/ngx_http_charset_filter_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_chunked_filter_module.c b/src/http/modules/ngx_http_chunked_filter_module.c
index e6ae1c99d..94313a8f6 100644
--- a/src/http/modules/ngx_http_chunked_filter_module.c
+++ b/src/http/modules/ngx_http_chunked_filter_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_dav_module.c b/src/http/modules/ngx_http_dav_module.c
index 3bd9d3e94..dbb17ac30 100644
--- a/src/http/modules/ngx_http_dav_module.c
+++ b/src/http/modules/ngx_http_dav_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_degradation_module.c b/src/http/modules/ngx_http_degradation_module.c
index a5f83bb20..0b1368f3b 100644
--- a/src/http/modules/ngx_http_degradation_module.c
+++ b/src/http/modules/ngx_http_degradation_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_empty_gif_module.c b/src/http/modules/ngx_http_empty_gif_module.c
index 7cef538ac..04114dc3f 100644
--- a/src/http/modules/ngx_http_empty_gif_module.c
+++ b/src/http/modules/ngx_http_empty_gif_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
#include <ngx_config.h>
diff --git a/src/http/modules/ngx_http_fastcgi_module.c b/src/http/modules/ngx_http_fastcgi_module.c
index 4a62f7197..78ebadc05 100644
--- a/src/http/modules/ngx_http_fastcgi_module.c
+++ b/src/http/modules/ngx_http_fastcgi_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_flv_module.c b/src/http/modules/ngx_http_flv_module.c
index 30af834ab..f6870235b 100644
--- a/src/http/modules/ngx_http_flv_module.c
+++ b/src/http/modules/ngx_http_flv_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
#include <ngx_config.h>
diff --git a/src/http/modules/ngx_http_geo_module.c b/src/http/modules/ngx_http_geo_module.c
index 7c5019605..1d7599e55 100644
--- a/src/http/modules/ngx_http_geo_module.c
+++ b/src/http/modules/ngx_http_geo_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_geoip_module.c b/src/http/modules/ngx_http_geoip_module.c
index 311a30ce3..60d67574d 100644
--- a/src/http/modules/ngx_http_geoip_module.c
+++ b/src/http/modules/ngx_http_geoip_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_gzip_filter_module.c b/src/http/modules/ngx_http_gzip_filter_module.c
index 18824059a..4429e01ba 100644
--- a/src/http/modules/ngx_http_gzip_filter_module.c
+++ b/src/http/modules/ngx_http_gzip_filter_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_gzip_static_module.c b/src/http/modules/ngx_http_gzip_static_module.c
index 9e3b1ad66..18c28d8f5 100644
--- a/src/http/modules/ngx_http_gzip_static_module.c
+++ b/src/http/modules/ngx_http_gzip_static_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_headers_filter_module.c b/src/http/modules/ngx_http_headers_filter_module.c
index 754473355..daa17623c 100644
--- a/src/http/modules/ngx_http_headers_filter_module.c
+++ b/src/http/modules/ngx_http_headers_filter_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_image_filter_module.c b/src/http/modules/ngx_http_image_filter_module.c
index 66ed34541..dd3c9cee5 100644
--- a/src/http/modules/ngx_http_image_filter_module.c
+++ b/src/http/modules/ngx_http_image_filter_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_index_module.c b/src/http/modules/ngx_http_index_module.c
index 15aeaf9c6..0835a7cf8 100644
--- a/src/http/modules/ngx_http_index_module.c
+++ b/src/http/modules/ngx_http_index_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_limit_conn_module.c b/src/http/modules/ngx_http_limit_conn_module.c
index 40f05a22e..f98e7bc51 100644
--- a/src/http/modules/ngx_http_limit_conn_module.c
+++ b/src/http/modules/ngx_http_limit_conn_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_limit_req_module.c b/src/http/modules/ngx_http_limit_req_module.c
index 779b397c2..e4d90a98f 100644
--- a/src/http/modules/ngx_http_limit_req_module.c
+++ b/src/http/modules/ngx_http_limit_req_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
@@ -17,6 +18,7 @@ typedef struct {
ngx_msec_t last;
/* integer value, 1 corresponds to 0.001 r/s */
ngx_uint_t excess;
+ ngx_uint_t count;
u_char data[1];
} ngx_http_limit_req_node_t;
@@ -35,6 +37,7 @@ typedef struct {
ngx_uint_t rate;
ngx_int_t index;
ngx_str_t var;
+ ngx_http_limit_req_node_t *node;
} ngx_http_limit_req_ctx_t;
@@ -42,16 +45,23 @@ typedef struct {
ngx_shm_zone_t *shm_zone;
/* integer value, 1 corresponds to 0.001 r/s */
ngx_uint_t burst;
+ ngx_uint_t nodelay; /* unsigned nodelay:1 */
+} ngx_http_limit_req_limit_t;
+
+
+typedef struct {
+ ngx_array_t limits;
ngx_uint_t limit_log_level;
ngx_uint_t delay_log_level;
-
- ngx_uint_t nodelay; /* unsigned nodelay:1 */
} ngx_http_limit_req_conf_t;
static void ngx_http_limit_req_delay(ngx_http_request_t *r);
-static ngx_int_t ngx_http_limit_req_lookup(ngx_http_limit_req_conf_t *lrcf,
- ngx_uint_t hash, u_char *data, size_t len, ngx_uint_t *ep);
+static ngx_int_t ngx_http_limit_req_lookup(ngx_http_limit_req_limit_t *limit,
+ ngx_uint_t hash, u_char *data, size_t len, ngx_uint_t *ep,
+ ngx_uint_t account);
+static ngx_msec_t ngx_http_limit_req_account(ngx_http_limit_req_limit_t *limits,
+ ngx_uint_t n, ngx_uint_t *ep, ngx_http_limit_req_limit_t **limit);
static void ngx_http_limit_req_expire(ngx_http_limit_req_ctx_t *ctx,
ngx_uint_t n);
@@ -135,123 +145,124 @@ ngx_module_t ngx_http_limit_req_module = {
static ngx_int_t
ngx_http_limit_req_handler(ngx_http_request_t *r)
{
- size_t len, n;
- uint32_t hash;
- ngx_int_t rc;
- ngx_uint_t excess;
- ngx_time_t *tp;
- ngx_rbtree_node_t *node;
- ngx_http_variable_value_t *vv;
- ngx_http_limit_req_ctx_t *ctx;
- ngx_http_limit_req_node_t *lr;
- ngx_http_limit_req_conf_t *lrcf;
+ size_t len;
+ uint32_t hash;
+ ngx_int_t rc;
+ ngx_uint_t n, excess;
+ ngx_msec_t delay;
+ ngx_http_variable_value_t *vv;
+ ngx_http_limit_req_ctx_t *ctx;
+ ngx_http_limit_req_conf_t *lrcf;
+ ngx_http_limit_req_limit_t *limit, *limits;
if (r->main->limit_req_set) {
return NGX_DECLINED;
}
lrcf = ngx_http_get_module_loc_conf(r, ngx_http_limit_req_module);
+ limits = lrcf->limits.elts;
- if (lrcf->shm_zone == NULL) {
- return NGX_DECLINED;
- }
+ excess = 0;
- ctx = lrcf->shm_zone->data;
+ rc = NGX_DECLINED;
- vv = ngx_http_get_indexed_variable(r, ctx->index);
+#if (NGX_SUPPRESS_WARN)
+ limit = NULL;
+#endif
- if (vv == NULL || vv->not_found) {
- return NGX_DECLINED;
- }
+ for (n = 0; n < lrcf->limits.nelts; n++) {
- len = vv->len;
+ limit = &limits[n];
- if (len == 0) {
- return NGX_DECLINED;
- }
+ ctx = limit->shm_zone->data;
- if (len > 65535) {
- ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
- "the value of the \"%V\" variable "
- "is more than 65535 bytes: \"%v\"",
- &ctx->var, vv);
- return NGX_DECLINED;
- }
+ vv = ngx_http_get_indexed_variable(r, ctx->index);
- r->main->limit_req_set = 1;
-
- hash = ngx_crc32_short(vv->data, len);
+ if (vv == NULL || vv->not_found) {
+ continue;
+ }
- ngx_shmtx_lock(&ctx->shpool->mutex);
+ len = vv->len;
- ngx_http_limit_req_expire(ctx, 1);
+ if (len == 0) {
+ continue;
+ }
- rc = ngx_http_limit_req_lookup(lrcf, hash, vv->data, len, &excess);
+ if (len > 65535) {
+ ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
+ "the value of the \"%V\" variable "
+ "is more than 65535 bytes: \"%v\"",
+ &ctx->var, vv);
+ continue;
+ }
- ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
- "limit_req: %i %ui.%03ui", rc, excess / 1000, excess % 1000);
+ hash = ngx_crc32_short(vv->data, len);
- if (rc == NGX_DECLINED) {
+ ngx_shmtx_lock(&ctx->shpool->mutex);
- n = offsetof(ngx_rbtree_node_t, color)
- + offsetof(ngx_http_limit_req_node_t, data)
- + len;
+ rc = ngx_http_limit_req_lookup(limit, hash, vv->data, len, &excess,
+ (n == lrcf->limits.nelts - 1));
- node = ngx_slab_alloc_locked(ctx->shpool, n);
- if (node == NULL) {
+ ngx_shmtx_unlock(&ctx->shpool->mutex);
- ngx_http_limit_req_expire(ctx, 0);
+ ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "limit_req[%ui]: %i %ui.%03ui",
+ n, rc, excess / 1000, excess % 1000);
- node = ngx_slab_alloc_locked(ctx->shpool, n);
- if (node == NULL) {
- ngx_shmtx_unlock(&ctx->shpool->mutex);
- return NGX_HTTP_SERVICE_UNAVAILABLE;
- }
+ if (rc != NGX_AGAIN) {
+ break;
}
+ }
- lr = (ngx_http_limit_req_node_t *) &node->color;
+ if (rc == NGX_DECLINED) {
+ return NGX_DECLINED;
+ }
- node->key = hash;
- lr->len = (u_char) len;
+ r->main->limit_req_set = 1;
- tp = ngx_timeofday();
- lr->last = (ngx_msec_t) (tp->sec * 1000 + tp->msec);
+ if (rc == NGX_BUSY || rc == NGX_ERROR) {
- lr->excess = 0;
- ngx_memcpy(lr->data, vv->data, len);
+ if (rc == NGX_BUSY) {
+ ngx_log_error(lrcf->limit_log_level, r->connection->log, 0,
+ "limiting requests, excess: %ui.%03ui by zone \"%V\"",
+ excess / 1000, excess % 1000,
+ &limit->shm_zone->shm.name);
+ }
- ngx_rbtree_insert(&ctx->sh->rbtree, node);
+ while (n--) {
+ ctx = limits[n].shm_zone->data;
- ngx_queue_insert_head(&ctx->sh->queue, &lr->queue);
+ if (ctx->node == NULL) {
+ continue;
+ }
- ngx_shmtx_unlock(&ctx->shpool->mutex);
+ ngx_shmtx_lock(&ctx->shpool->mutex);
- return NGX_DECLINED;
- }
+ ctx->node->count--;
- ngx_shmtx_unlock(&ctx->shpool->mutex);
+ ngx_shmtx_unlock(&ctx->shpool->mutex);
- if (rc == NGX_OK) {
- return NGX_DECLINED;
+ ctx->node = NULL;
+ }
+
+ return NGX_HTTP_SERVICE_UNAVAILABLE;
}
- if (rc == NGX_BUSY) {
- ngx_log_error(lrcf->limit_log_level, r->connection->log, 0,
- "limiting requests, excess: %ui.%03ui by zone \"%V\"",
- excess / 1000, excess % 1000, &lrcf->shm_zone->shm.name);
+ /* rc == NGX_AGAIN || rc == NGX_OK */
- return NGX_HTTP_SERVICE_UNAVAILABLE;
+ if (rc == NGX_AGAIN) {
+ excess = 0;
}
- /* rc == NGX_AGAIN */
+ delay = ngx_http_limit_req_account(limits, n, &excess, &limit);
- if (lrcf->nodelay) {
+ if (!delay) {
return NGX_DECLINED;
}
ngx_log_error(lrcf->delay_log_level, r->connection->log, 0,
"delaying request, excess: %ui.%03ui, by zone \"%V\"",
- excess / 1000, excess % 1000, &lrcf->shm_zone->shm.name);
+ excess / 1000, excess % 1000, &limit->shm_zone->shm.name);
if (ngx_handle_read_event(r->connection->read, 0) != NGX_OK) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
@@ -259,8 +270,7 @@ ngx_http_limit_req_handler(ngx_http_request_t *r)
r->read_event_handler = ngx_http_test_reading;
r->write_event_handler = ngx_http_limit_req_delay;
- ngx_add_timer(r->connection->write,
- (ngx_msec_t) excess * 1000 / ctx->rate);
+ ngx_add_timer(r->connection->write, delay);
return NGX_AGAIN;
}
@@ -341,9 +351,10 @@ ngx_http_limit_req_rbtree_insert_value(ngx_rbtree_node_t *temp,
static ngx_int_t
-ngx_http_limit_req_lookup(ngx_http_limit_req_conf_t *lrcf, ngx_uint_t hash,
- u_char *data, size_t len, ngx_uint_t *ep)
+ngx_http_limit_req_lookup(ngx_http_limit_req_limit_t *limit, ngx_uint_t hash,
+ u_char *data, size_t len, ngx_uint_t *ep, ngx_uint_t account)
{
+ size_t size;
ngx_int_t rc, excess;
ngx_time_t *tp;
ngx_msec_t now;
@@ -352,7 +363,10 @@ ngx_http_limit_req_lookup(ngx_http_limit_req_conf_t *lrcf, ngx_uint_t hash,
ngx_http_limit_req_ctx_t *ctx;
ngx_http_limit_req_node_t *lr;
- ctx = lrcf->shm_zone->data;
+ tp = ngx_timeofday();
+ now = (ngx_msec_t) (tp->sec * 1000 + tp->msec);
+
+ ctx = limit->shm_zone->data;
node = ctx->sh->rbtree.root;
sentinel = ctx->sh->rbtree.sentinel;
@@ -380,9 +394,6 @@ ngx_http_limit_req_lookup(ngx_http_limit_req_conf_t *lrcf, ngx_uint_t hash,
ngx_queue_remove(&lr->queue);
ngx_queue_insert_head(&ctx->sh->queue, &lr->queue);
- tp = ngx_timeofday();
-
- now = (ngx_msec_t) (tp->sec * 1000 + tp->msec);
ms = (ngx_msec_int_t) (now - lr->last);
excess = lr->excess - ctx->rate * ngx_abs(ms) / 1000 + 1000;
@@ -393,18 +404,21 @@ ngx_http_limit_req_lookup(ngx_http_limit_req_conf_t *lrcf, ngx_uint_t hash,
*ep = excess;
- if ((ngx_uint_t) excess > lrcf->burst) {
+ if ((ngx_uint_t) excess > limit->burst) {
return NGX_BUSY;
}
- lr->excess = excess;
- lr->last = now;
-
- if (excess) {
- return NGX_AGAIN;
+ if (account) {
+ lr->excess = excess;
+ lr->last = now;
+ return NGX_OK;
}
- return NGX_OK;
+ lr->count++;
+
+ ctx->node = lr;
+
+ return NGX_AGAIN;
}
node = (rc < 0) ? node->left : node->right;
@@ -416,7 +430,115 @@ ngx_http_limit_req_lookup(ngx_http_limit_req_conf_t *lrcf, ngx_uint_t hash,
*ep = 0;
- return NGX_DECLINED;
+ size = offsetof(ngx_rbtree_node_t, color)
+ + offsetof(ngx_http_limit_req_node_t, data)
+ + len;
+
+ ngx_http_limit_req_expire(ctx, 1);
+
+ node = ngx_slab_alloc_locked(ctx->shpool, size);
+
+ if (node == NULL) {
+ ngx_http_limit_req_expire(ctx, 0);
+
+ node = ngx_slab_alloc_locked(ctx->shpool, size);
+ if (node == NULL) {
+ return NGX_ERROR;
+ }
+ }
+
+ node->key = hash;
+
+ ngx_rbtree_insert(&ctx->sh->rbtree, node);
+
+ lr = (ngx_http_limit_req_node_t *) &node->color;
+
+ ngx_queue_insert_head(&ctx->sh->queue, &lr->queue);
+
+ lr->len = (u_char) len;
+ lr->excess = 0;
+
+ ngx_memcpy(lr->data, data, len);
+
+ if (account) {
+ lr->last = now;
+ lr->count = 0;
+ return NGX_OK;
+ }
+
+ lr->last = 0;
+ lr->count = 1;
+
+ ctx->node = lr;
+
+ return NGX_AGAIN;
+}
+
+
+static ngx_msec_t
+ngx_http_limit_req_account(ngx_http_limit_req_limit_t *limits, ngx_uint_t n,
+ ngx_uint_t *ep, ngx_http_limit_req_limit_t **limit)
+{
+ ngx_int_t excess;
+ ngx_time_t *tp;
+ ngx_msec_t now, delay, max_delay;
+ ngx_msec_int_t ms;
+ ngx_http_limit_req_ctx_t *ctx;
+ ngx_http_limit_req_node_t *lr;
+
+ excess = *ep;
+
+ if (excess == 0 || (*limit)->nodelay) {
+ max_delay = 0;
+
+ } else {
+ ctx = (*limit)->shm_zone->data;
+ max_delay = excess * 1000 / ctx->rate;
+ }
+
+ while (n--) {
+ ctx = limits[n].shm_zone->data;
+ lr = ctx->node;
+
+ if (lr == NULL) {
+ continue;
+ }
+
+ ngx_shmtx_lock(&ctx->shpool->mutex);
+
+ tp = ngx_timeofday();
+
+ now = (ngx_msec_t) (tp->sec * 1000 + tp->msec);
+ ms = (ngx_msec_int_t) (now - lr->last);
+
+ excess = lr->excess - ctx->rate * ngx_abs(ms) / 1000 + 1000;
+
+ if (excess < 0) {
+ excess = 0;
+ }
+
+ lr->last = now;
+ lr->excess = excess;
+ lr->count--;
+
+ ngx_shmtx_unlock(&ctx->shpool->mutex);
+
+ ctx->node = NULL;
+
+ if (limits[n].nodelay) {
+ continue;
+ }
+
+ delay = excess * 1000 / ctx->rate;
+
+ if (delay > max_delay) {
+ max_delay = delay;
+ *ep = excess;
+ *limit = &limits[n];
+ }
+ }
+
+ return max_delay;
}
@@ -451,6 +573,16 @@ ngx_http_limit_req_expire(ngx_http_limit_req_ctx_t *ctx, ngx_uint_t n)
lr = ngx_queue_data(q, ngx_http_limit_req_node_t, queue);
+ if (lr->count) {
+
+ /*
+ * There is not much sense in looking further,
+ * because we bump nodes on the lookup stage.
+ */
+
+ return;
+ }
+
if (n++ != 0) {
ms = (ngx_msec_int_t) (now - lr->last);
@@ -551,9 +683,7 @@ ngx_http_limit_req_create_conf(ngx_conf_t *cf)
/*
* set by ngx_pcalloc():
*
- * conf->shm_zone = NULL;
- * conf->burst = 0;
- * conf->nodelay = 0;
+ * conf->limits.elts = NULL;
*/
conf->limit_log_level = NGX_CONF_UNSET_UINT;
@@ -568,10 +698,8 @@ ngx_http_limit_req_merge_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_http_limit_req_conf_t *prev = parent;
ngx_http_limit_req_conf_t *conf = child;
- if (conf->shm_zone == NULL) {
- conf->shm_zone = prev->shm_zone;
- conf->burst = prev->burst;
- conf->nodelay = prev->nodelay;
+ if (conf->limits.elts == NULL) {
+ conf->limits = prev->limits;
}
ngx_conf_merge_uint_value(conf->limit_log_level, prev->limit_log_level,
@@ -588,7 +716,8 @@ static char *
ngx_http_limit_req_zone(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
u_char *p;
- size_t size, len;
+ size_t len;
+ ssize_t size;
ngx_str_t *value, name, s;
ngx_int_t rate, scale;
ngx_uint_t i;
@@ -611,25 +740,32 @@ ngx_http_limit_req_zone(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
p = (u_char *) ngx_strchr(name.data, ':');
- if (p) {
- *p = '\0';
+ if (p == NULL) {
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "invalid zone size \"%V\"", &value[i]);
+ return NGX_CONF_ERROR;
+ }
- name.len = p - name.data;
+ name.len = p - name.data;
- p++;
+ s.data = p + 1;
+ s.len = value[i].data + value[i].len - s.data;
- s.len = value[i].data + value[i].len - p;
- s.data = p;
+ size = ngx_parse_size(&s);
- size = ngx_parse_size(&s);
- if (size > 8191) {
- continue;
- }
+ if (size == NGX_ERROR) {
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "invalid zone size \"%V\"", &value[i]);
+ return NGX_CONF_ERROR;
}
- ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
- "invalid zone size \"%V\"", &value[i]);
- return NGX_CONF_ERROR;
+ if (size < (ssize_t) (8 * ngx_pagesize)) {
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "zone \"%V\" is too small", &value[i]);
+ return NGX_CONF_ERROR;
+ }
+
+ continue;
}
if (ngx_strncmp(value[i].data, "rate=", 5) == 0) {
@@ -681,7 +817,7 @@ ngx_http_limit_req_zone(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return NGX_CONF_ERROR;
}
- if (name.len == 0 || size == 0) {
+ if (name.len == 0) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"\"%V\" must have \"zone\" parameter",
&cmd->name);
@@ -690,8 +826,8 @@ ngx_http_limit_req_zone(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
if (ctx == NULL) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
- "no variable is defined for limit_req_zone \"%V\"",
- &cmd->name);
+ "no variable is defined for %V \"%V\"",
+ &cmd->name, &name);
return NGX_CONF_ERROR;
}
@@ -707,8 +843,8 @@ ngx_http_limit_req_zone(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ctx = shm_zone->data;
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
- "limit_req_zone \"%V\" is already bound to variable \"%V\"",
- &value[1], &ctx->var);
+ "%V \"%V\" is already bound to variable \"%V\"",
+ &cmd->name, &name, &ctx->var);
return NGX_CONF_ERROR;
}
@@ -724,17 +860,17 @@ ngx_http_limit_req(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
ngx_http_limit_req_conf_t *lrcf = conf;
- ngx_int_t burst;
- ngx_str_t *value, s;
- ngx_uint_t i;
-
- if (lrcf->shm_zone) {
- return "is duplicate";
- }
+ ngx_int_t burst;
+ ngx_str_t *value, s;
+ ngx_uint_t i, nodelay;
+ ngx_shm_zone_t *shm_zone;
+ ngx_http_limit_req_limit_t *limit, *limits;
value = cf->args->elts;
+ shm_zone = NULL;
burst = 0;
+ nodelay = 0;
for (i = 1; i < cf->args->nelts; i++) {
@@ -743,9 +879,9 @@ ngx_http_limit_req(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
s.len = value[i].len - 5;
s.data = value[i].data + 5;
- lrcf->shm_zone = ngx_shared_memory_add(cf, &s, 0,
- &ngx_http_limit_req_module);
- if (lrcf->shm_zone == NULL) {
+ shm_zone = ngx_shared_memory_add(cf, &s, 0,
+ &ngx_http_limit_req_module);
+ if (shm_zone == NULL) {
return NGX_CONF_ERROR;
}
@@ -765,7 +901,7 @@ ngx_http_limit_req(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
}
if (ngx_strncmp(value[i].data, "nodelay", 7) == 0) {
- lrcf->nodelay = 1;
+ nodelay = 1;
continue;
}
@@ -774,21 +910,42 @@ ngx_http_limit_req(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return NGX_CONF_ERROR;
}
- if (lrcf->shm_zone == NULL) {
+ if (shm_zone == NULL) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"\"%V\" must have \"zone\" parameter",
&cmd->name);
return NGX_CONF_ERROR;
}
- if (lrcf->shm_zone->data == NULL) {
+ if (shm_zone->data == NULL) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"unknown limit_req_zone \"%V\"",
- &lrcf->shm_zone->shm.name);
+ &shm_zone->shm.name);
return NGX_CONF_ERROR;
}
- lrcf->burst = burst * 1000;
+ limits = lrcf->limits.elts;
+
+ if (limits == NULL) {
+ if (ngx_array_init(&lrcf->limits, cf->pool, 1,
+ sizeof(ngx_http_limit_req_limit_t))
+ != NGX_OK)
+ {
+ return NGX_CONF_ERROR;
+ }
+ }
+
+ for (i = 0; i < lrcf->limits.nelts; i++) {
+ if (shm_zone == limits[i].shm_zone) {
+ return "is duplicate";
+ }
+ }
+
+ limit = ngx_array_push(&lrcf->limits);
+
+ limit->shm_zone = shm_zone;
+ limit->burst = burst * 1000;
+ limit->nodelay = nodelay;
return NGX_CONF_OK;
}
diff --git a/src/http/modules/ngx_http_log_module.c b/src/http/modules/ngx_http_log_module.c
index cb9c77f6f..c55131772 100644
--- a/src/http/modules/ngx_http_log_module.c
+++ b/src/http/modules/ngx_http_log_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_map_module.c b/src/http/modules/ngx_http_map_module.c
index 6b724b304..2fe925f1c 100644
--- a/src/http/modules/ngx_http_map_module.c
+++ b/src/http/modules/ngx_http_map_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_memcached_module.c b/src/http/modules/ngx_http_memcached_module.c
index dbe0fe838..be45d4eeb 100644
--- a/src/http/modules/ngx_http_memcached_module.c
+++ b/src/http/modules/ngx_http_memcached_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_mp4_module.c b/src/http/modules/ngx_http_mp4_module.c
index 6de7c8fea..816cc4c83 100644
--- a/src/http/modules/ngx_http_mp4_module.c
+++ b/src/http/modules/ngx_http_mp4_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
#include <ngx_config.h>
diff --git a/src/http/modules/ngx_http_not_modified_filter_module.c b/src/http/modules/ngx_http_not_modified_filter_module.c
index a778c70dc..488c36b72 100644
--- a/src/http/modules/ngx_http_not_modified_filter_module.c
+++ b/src/http/modules/ngx_http_not_modified_filter_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_proxy_module.c b/src/http/modules/ngx_http_proxy_module.c
index b6aa38b53..fb86f0106 100644
--- a/src/http/modules/ngx_http_proxy_module.c
+++ b/src/http/modules/ngx_http_proxy_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
@@ -3291,6 +3292,8 @@ ngx_http_proxy_redirect(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return NGX_CONF_OK;
}
+ plcf->redirect = 1;
+
value = cf->args->elts;
if (cf->args->nelts == 2) {
diff --git a/src/http/modules/ngx_http_random_index_module.c b/src/http/modules/ngx_http_random_index_module.c
index 02bdc45f9..67f34f739 100644
--- a/src/http/modules/ngx_http_random_index_module.c
+++ b/src/http/modules/ngx_http_random_index_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_range_filter_module.c b/src/http/modules/ngx_http_range_filter_module.c
index 02d2bf925..3380e5e0e 100644
--- a/src/http/modules/ngx_http_range_filter_module.c
+++ b/src/http/modules/ngx_http_range_filter_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_realip_module.c b/src/http/modules/ngx_http_realip_module.c
index b88b12242..bb606beb7 100644
--- a/src/http/modules/ngx_http_realip_module.c
+++ b/src/http/modules/ngx_http_realip_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_referer_module.c b/src/http/modules/ngx_http_referer_module.c
index cf2d744f1..d8a014c5b 100644
--- a/src/http/modules/ngx_http_referer_module.c
+++ b/src/http/modules/ngx_http_referer_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_rewrite_module.c b/src/http/modules/ngx_http_rewrite_module.c
index 2ef24405c..98da67f27 100644
--- a/src/http/modules/ngx_http_rewrite_module.c
+++ b/src/http/modules/ngx_http_rewrite_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_scgi_module.c b/src/http/modules/ngx_http_scgi_module.c
index 2ab9ee85c..538557377 100644
--- a/src/http/modules/ngx_http_scgi_module.c
+++ b/src/http/modules/ngx_http_scgi_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
* Copyright (C) Manlio Perillo (manlio.perillo@gmail.com)
*/
diff --git a/src/http/modules/ngx_http_secure_link_module.c b/src/http/modules/ngx_http_secure_link_module.c
index 6c4be6191..b69b5526f 100644
--- a/src/http/modules/ngx_http_secure_link_module.c
+++ b/src/http/modules/ngx_http_secure_link_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_split_clients_module.c b/src/http/modules/ngx_http_split_clients_module.c
index 0b726f777..f2160b149 100644
--- a/src/http/modules/ngx_http_split_clients_module.c
+++ b/src/http/modules/ngx_http_split_clients_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_ssi_filter_module.c b/src/http/modules/ngx_http_ssi_filter_module.c
index e33782166..b02300f39 100644
--- a/src/http/modules/ngx_http_ssi_filter_module.c
+++ b/src/http/modules/ngx_http_ssi_filter_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_ssi_filter_module.h b/src/http/modules/ngx_http_ssi_filter_module.h
index 2b0018662..0bd01a067 100644
--- a/src/http/modules/ngx_http_ssi_filter_module.h
+++ b/src/http/modules/ngx_http_ssi_filter_module.h
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_ssl_module.c b/src/http/modules/ngx_http_ssl_module.c
index 17a5b8de2..d759489a6 100644
--- a/src/http/modules/ngx_http_ssl_module.c
+++ b/src/http/modules/ngx_http_ssl_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_ssl_module.h b/src/http/modules/ngx_http_ssl_module.h
index 0a5dd1d8d..58659ab95 100644
--- a/src/http/modules/ngx_http_ssl_module.h
+++ b/src/http/modules/ngx_http_ssl_module.h
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_static_module.c b/src/http/modules/ngx_http_static_module.c
index cea050a94..a0e302ad1 100644
--- a/src/http/modules/ngx_http_static_module.c
+++ b/src/http/modules/ngx_http_static_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_stub_status_module.c b/src/http/modules/ngx_http_stub_status_module.c
index 4b74eb884..f78086981 100644
--- a/src/http/modules/ngx_http_stub_status_module.c
+++ b/src/http/modules/ngx_http_stub_status_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_sub_filter_module.c b/src/http/modules/ngx_http_sub_filter_module.c
index ddc69ba52..be5e90c4e 100644
--- a/src/http/modules/ngx_http_sub_filter_module.c
+++ b/src/http/modules/ngx_http_sub_filter_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_upstream_ip_hash_module.c b/src/http/modules/ngx_http_upstream_ip_hash_module.c
index 4c031eb47..100ea34dd 100644
--- a/src/http/modules/ngx_http_upstream_ip_hash_module.c
+++ b/src/http/modules/ngx_http_upstream_ip_hash_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_upstream_keepalive_module.c b/src/http/modules/ngx_http_upstream_keepalive_module.c
index 945f78b15..6fd9ac70a 100644
--- a/src/http/modules/ngx_http_upstream_keepalive_module.c
+++ b/src/http/modules/ngx_http_upstream_keepalive_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Maxim Dounin
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_userid_filter_module.c b/src/http/modules/ngx_http_userid_filter_module.c
index 195d9dc4f..894e2c14e 100644
--- a/src/http/modules/ngx_http_userid_filter_module.c
+++ b/src/http/modules/ngx_http_userid_filter_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_uwsgi_module.c b/src/http/modules/ngx_http_uwsgi_module.c
index f28d9aa0f..73bbdda4d 100644
--- a/src/http/modules/ngx_http_uwsgi_module.c
+++ b/src/http/modules/ngx_http_uwsgi_module.c
@@ -3,6 +3,7 @@
* Copyright (C) Unbit S.a.s. 2009-2010
* Copyright (C) 2008 Manlio Perillo (manlio.perillo@gmail.com)
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/ngx_http_xslt_filter_module.c b/src/http/modules/ngx_http_xslt_filter_module.c
index d67ec8047..f86c30381 100644
--- a/src/http/modules/ngx_http_xslt_filter_module.c
+++ b/src/http/modules/ngx_http_xslt_filter_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/perl/Makefile.PL b/src/http/modules/perl/Makefile.PL
index c33b1fc72..6575f284c 100644
--- a/src/http/modules/perl/Makefile.PL
+++ b/src/http/modules/perl/Makefile.PL
@@ -1,5 +1,6 @@
# Copyright (C) Igor Sysoev
+# Copyright (C) Nginx, Inc.
use 5.006001;
use ExtUtils::MakeMaker;
diff --git a/src/http/modules/perl/nginx.pm b/src/http/modules/perl/nginx.pm
index 01e977646..7f060d745 100644
--- a/src/http/modules/perl/nginx.pm
+++ b/src/http/modules/perl/nginx.pm
@@ -48,7 +48,7 @@ our @EXPORT = qw(
HTTP_INSUFFICIENT_STORAGE
);
-our $VERSION = '1.1.13';
+our $VERSION = '1.1.14';
require XSLoader;
XSLoader::load('nginx', $VERSION);
@@ -128,6 +128,7 @@ Igor Sysoev
=head1 COPYRIGHT AND LICENSE
Copyright (C) Igor Sysoev
+Copyright (C) Nginx, Inc.
=cut
diff --git a/src/http/modules/perl/nginx.xs b/src/http/modules/perl/nginx.xs
index e3a9dd5c9..dc69d509a 100644
--- a/src/http/modules/perl/nginx.xs
+++ b/src/http/modules/perl/nginx.xs
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/perl/ngx_http_perl_module.c b/src/http/modules/perl/ngx_http_perl_module.c
index d89e96a57..90e32e80e 100644
--- a/src/http/modules/perl/ngx_http_perl_module.c
+++ b/src/http/modules/perl/ngx_http_perl_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/modules/perl/ngx_http_perl_module.h b/src/http/modules/perl/ngx_http_perl_module.h
index 23969bcd4..5e60b031e 100644
--- a/src/http/modules/perl/ngx_http_perl_module.h
+++ b/src/http/modules/perl/ngx_http_perl_module.h
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/ngx_http.c b/src/http/ngx_http.c
index e10dbc88d..27580f195 100644
--- a/src/http/ngx_http.c
+++ b/src/http/ngx_http.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/ngx_http.h b/src/http/ngx_http.h
index 3c1a9d275..f152006a0 100644
--- a/src/http/ngx_http.h
+++ b/src/http/ngx_http.h
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/ngx_http_busy_lock.c b/src/http/ngx_http_busy_lock.c
index fd3824331..35a03acaa 100644
--- a/src/http/ngx_http_busy_lock.c
+++ b/src/http/ngx_http_busy_lock.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/ngx_http_busy_lock.h b/src/http/ngx_http_busy_lock.h
index d793e2966..c676382f2 100644
--- a/src/http/ngx_http_busy_lock.h
+++ b/src/http/ngx_http_busy_lock.h
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/ngx_http_cache.h b/src/http/ngx_http_cache.h
index ae8b8c376..2a2d72291 100644
--- a/src/http/ngx_http_cache.h
+++ b/src/http/ngx_http_cache.h
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/ngx_http_config.h b/src/http/ngx_http_config.h
index 435ce9a84..2208c601b 100644
--- a/src/http/ngx_http_config.h
+++ b/src/http/ngx_http_config.h
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/ngx_http_copy_filter_module.c b/src/http/ngx_http_copy_filter_module.c
index 0f9917e2e..d52fbebe8 100644
--- a/src/http/ngx_http_copy_filter_module.c
+++ b/src/http/ngx_http_copy_filter_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
@@ -189,7 +190,7 @@ ngx_http_copy_filter(ngx_http_request_t *r, ngx_chain_t *in)
rc = n;
- if (file->aio) {
+ if (rc == NGX_AGAIN) {
file->aio->data = r;
file->aio->handler = ngx_http_copy_aio_sendfile_event_handler;
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 1d5ee5dc6..251f932fd 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h
index 73e39e3b9..38f58dfcb 100644
--- a/src/http/ngx_http_core_module.h
+++ b/src/http/ngx_http_core_module.h
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/ngx_http_file_cache.c b/src/http/ngx_http_file_cache.c
index dccbbac68..4840233ed 100644
--- a/src/http/ngx_http_file_cache.c
+++ b/src/http/ngx_http_file_cache.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/ngx_http_header_filter_module.c b/src/http/ngx_http_header_filter_module.c
index 2f8a38dad..1d8fee9d7 100644
--- a/src/http/ngx_http_header_filter_module.c
+++ b/src/http/ngx_http_header_filter_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/ngx_http_parse.c b/src/http/ngx_http_parse.c
index 28842cf9d..956259eef 100644
--- a/src/http/ngx_http_parse.c
+++ b/src/http/ngx_http_parse.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/ngx_http_parse_time.c b/src/http/ngx_http_parse_time.c
index 2e7b40add..7d3aeaeff 100644
--- a/src/http/ngx_http_parse_time.c
+++ b/src/http/ngx_http_parse_time.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/ngx_http_postpone_filter_module.c b/src/http/ngx_http_postpone_filter_module.c
index 156401b32..cf49b2fa8 100644
--- a/src/http/ngx_http_postpone_filter_module.c
+++ b/src/http/ngx_http_postpone_filter_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index fbb7915b3..2b3f0065b 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h
index e851efa03..220aa139b 100644
--- a/src/http/ngx_http_request.h
+++ b/src/http/ngx_http_request.h
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/ngx_http_request_body.c b/src/http/ngx_http_request_body.c
index 817b48e45..ac09d56f1 100644
--- a/src/http/ngx_http_request_body.c
+++ b/src/http/ngx_http_request_body.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/ngx_http_script.c b/src/http/ngx_http_script.c
index 6d81b4435..77ac9a629 100644
--- a/src/http/ngx_http_script.c
+++ b/src/http/ngx_http_script.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/ngx_http_script.h b/src/http/ngx_http_script.h
index c5b1e4066..46592ab01 100644
--- a/src/http/ngx_http_script.h
+++ b/src/http/ngx_http_script.h
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/ngx_http_special_response.c b/src/http/ngx_http_special_response.c
index d30b781e5..a07ebe28d 100644
--- a/src/http/ngx_http_special_response.c
+++ b/src/http/ngx_http_special_response.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
index 781ef1f96..ba21c0135 100644
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/ngx_http_upstream.h b/src/http/ngx_http_upstream.h
index 62cbf533e..d99b904fb 100644
--- a/src/http/ngx_http_upstream.h
+++ b/src/http/ngx_http_upstream.h
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/ngx_http_upstream_round_robin.c b/src/http/ngx_http_upstream_round_robin.c
index 138872c5f..410559d50 100644
--- a/src/http/ngx_http_upstream_round_robin.c
+++ b/src/http/ngx_http_upstream_round_robin.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/ngx_http_upstream_round_robin.h b/src/http/ngx_http_upstream_round_robin.h
index 195f4d8ca..4b70f2f5b 100644
--- a/src/http/ngx_http_upstream_round_robin.h
+++ b/src/http/ngx_http_upstream_round_robin.h
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/ngx_http_variables.c b/src/http/ngx_http_variables.c
index 840519ef9..d6bb92c98 100644
--- a/src/http/ngx_http_variables.c
+++ b/src/http/ngx_http_variables.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/ngx_http_variables.h b/src/http/ngx_http_variables.h
index b0114e300..d2bb4db88 100644
--- a/src/http/ngx_http_variables.h
+++ b/src/http/ngx_http_variables.h
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/
diff --git a/src/http/ngx_http_write_filter_module.c b/src/http/ngx_http_write_filter_module.c
index a9660ee1f..72b1f9b2f 100644
--- a/src/http/ngx_http_write_filter_module.c
+++ b/src/http/ngx_http_write_filter_module.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
*/