Skip to content

Commit 2f9d0f8

Browse files
committed
fixed various minor issues in shoki's patch for the srcache_store_max_size feature.
1 parent ff59b80 commit 2f9d0f8

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

README

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ Directives
115115

116116
srcache_store
117117

118-
srcache_store_max_size
118+
srcache_store_max_size
119119

120120
Installation
121121
1. Grab the nginx source code from nginx.net (< http://nginx.net/ >), for

src/ngx_http_srcache_filter_module.c

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,14 @@ ngx_http_srcache_header_filter(ngx_http_request_t *r)
205205
return ngx_http_next_header_filter(r);
206206
}
207207

208-
if (slcf->store_max_size != 0
209-
&& r->headers_out.content_length_n >= (int) slcf->store_max_size) {
210-
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
211-
"bypass because of too large content-length header: %d (limit is: %d)",
212-
r->headers_out.content_length_n, slcf->store_max_size);
208+
if (slcf->store_max_size != 0
209+
&& r->headers_out.content_length_n > (off_t) slcf->store_max_size)
210+
{
211+
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
212+
"bypass because of too large content-length header: "
213+
"%O (limit is: %z)", r->headers_out.content_length_n,
214+
slcf->store_max_size);
215+
213216
return ngx_http_next_header_filter(r);
214217
}
215218

@@ -294,12 +297,11 @@ ngx_http_srcache_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
294297
{
295298
ngx_http_request_t *pr;
296299
ngx_http_srcache_ctx_t *ctx, *pr_ctx;
297-
ngx_int_t rc;
300+
ngx_int_t rc;
298301
ngx_chain_t *cl;
299-
ngx_flag_t last;
302+
ngx_flag_t last;
300303
ngx_http_srcache_loc_conf_t *slcf;
301304

302-
303305
dd_enter();
304306

305307
if (in == NULL) {
@@ -383,12 +385,16 @@ ngx_http_srcache_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
383385
}
384386

385387
slcf = ngx_http_get_module_loc_conf(r, ngx_http_srcache_filter_module);
386-
if (slcf->store_max_size != 0
387-
&& ctx->body_length >= slcf->store_max_size) {
388-
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
389-
"bypass because body reached maximum size: %d (limit is: %d)",
390-
ctx->body_length, slcf->store_max_size);
388+
389+
if (slcf->store_max_size != 0
390+
&& ctx->body_length > slcf->store_max_size)
391+
{
392+
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
393+
"bypass because body exceeded maximum size: %z "
394+
"(limit is: %z)", ctx->body_length, slcf->store_max_size);
395+
391396
ctx->store_response = 0;
397+
392398
goto done;
393399
}
394400

@@ -502,8 +508,7 @@ ngx_http_srcache_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
502508
ngx_conf_merge_size_value(conf->buf_size, prev->buf_size,
503509
(size_t) ngx_pagesize);
504510

505-
ngx_conf_merge_size_value(conf->store_max_size, prev->store_max_size,
506-
0);
511+
ngx_conf_merge_size_value(conf->store_max_size, prev->store_max_size, 0);
507512

508513
return NGX_CONF_OK;
509514
}

0 commit comments

Comments
 (0)