summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoman Arutyunyan <arut@nginx.com>2017-03-28 14:03:57 +0300
committerRoman Arutyunyan <arut@nginx.com>2017-03-28 14:03:57 +0300
commit8c9a66298c627ed4eae2557b322c3f33da97eca4 (patch)
tree71a55baa1b2095e86827e5de9845f5b2dde051cf
parent5d5f0dcac4e3bbd4464aa1185d7fd51587a3119e (diff)
Slice filter: allowed at most one subrequest at a time.
Previously, if slice main request write handler was called while a slice subrequest was running, a new subrequest for the same slice was started.
-rw-r--r--src/http/modules/ngx_http_slice_filter_module.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/http/modules/ngx_http_slice_filter_module.c b/src/http/modules/ngx_http_slice_filter_module.c
index 200593959..a3b2dde6e 100644
--- a/src/http/modules/ngx_http_slice_filter_module.c
+++ b/src/http/modules/ngx_http_slice_filter_module.c
@@ -11,23 +11,24 @@
typedef struct {
- size_t size;
+ size_t size;
} ngx_http_slice_loc_conf_t;
typedef struct {
- off_t start;
- off_t end;
- ngx_str_t range;
- ngx_str_t etag;
- ngx_uint_t last; /* unsigned last:1; */
+ off_t start;
+ off_t end;
+ ngx_str_t range;
+ ngx_str_t etag;
+ ngx_uint_t last; /* unsigned last:1; */
+ ngx_http_request_t *sr;
} ngx_http_slice_ctx_t;
typedef struct {
- off_t start;
- off_t end;
- off_t complete_length;
+ off_t start;
+ off_t end;
+ off_t complete_length;
} ngx_http_slice_content_range_t;
@@ -209,7 +210,6 @@ ngx_http_slice_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
{
ngx_int_t rc;
ngx_chain_t *cl;
- ngx_http_request_t *sr;
ngx_http_slice_ctx_t *ctx;
ngx_http_slice_loc_conf_t *slcf;
@@ -234,6 +234,10 @@ ngx_http_slice_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
return rc;
}
+ if (ctx->sr && !ctx->sr->done) {
+ return rc;
+ }
+
if (ctx->start >= ctx->end) {
ngx_http_set_ctx(r, NULL, ngx_http_slice_filter_module);
ngx_http_send_special(r, NGX_HTTP_LAST);
@@ -244,14 +248,14 @@ ngx_http_slice_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
return rc;
}
- if (ngx_http_subrequest(r, &r->uri, &r->args, &sr, NULL,
+ if (ngx_http_subrequest(r, &r->uri, &r->args, &ctx->sr, NULL,
NGX_HTTP_SUBREQUEST_CLONE)
!= NGX_OK)
{
return NGX_ERROR;
}
- ngx_http_set_ctx(sr, ctx, ngx_http_slice_filter_module);
+ ngx_http_set_ctx(ctx->sr, ctx, ngx_http_slice_filter_module);
slcf = ngx_http_get_module_loc_conf(r, ngx_http_slice_filter_module);