comparison src/http/modules/ngx_http_gzip_filter_module.c @ 2288:c28e47fb834c

do not pass gzheader separately as due to the previous commit we do not use ctx->busy as flush condition
author Igor Sysoev <igor@sysoev.ru>
date Wed, 05 Nov 2008 16:27:45 +0000
parents baa61933d5ed
children 1a7567e5b988
comparison
equal deleted inserted replaced
2287:baa61933d5ed 2288:c28e47fb834c
263 ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in) 263 ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
264 { 264 {
265 int rc, wbits, memlevel; 265 int rc, wbits, memlevel;
266 struct gztrailer *trailer; 266 struct gztrailer *trailer;
267 ngx_buf_t *b; 267 ngx_buf_t *b;
268 ngx_chain_t *cl, out; 268 ngx_chain_t *cl;
269 ngx_http_gzip_ctx_t *ctx; 269 ngx_http_gzip_ctx_t *ctx;
270 ngx_http_gzip_conf_t *conf; 270 ngx_http_gzip_conf_t *conf;
271 271
272 ctx = ngx_http_get_module_ctx(r, ngx_http_gzip_filter_module); 272 ctx = ngx_http_get_module_ctx(r, ngx_http_gzip_filter_module);
273 273
334 334
335 b->memory = 1; 335 b->memory = 1;
336 b->pos = gzheader; 336 b->pos = gzheader;
337 b->last = b->pos + 10; 337 b->last = b->pos + 10;
338 338
339 out.buf = b; 339 cl = ngx_alloc_chain_link(r->pool);
340 out.next = NULL; 340 if (cl == NULL) {
341
342 /*
343 * We pass the gzheader to the next filter now to avoid its linking
344 * to the ctx->busy chain. zlib does not usually output the compressed
345 * data in the initial iterations, so the gzheader that was linked
346 * to the ctx->busy chain would be flushed by ngx_http_write_filter().
347 */
348
349 if (ngx_http_next_body_filter(r, &out) == NGX_ERROR) {
350 ngx_http_gzip_error(ctx); 341 ngx_http_gzip_error(ctx);
351 return NGX_ERROR; 342 return NGX_ERROR;
352 } 343 }
353 344
345 cl->buf = b;
346 cl->next = NULL;
347 ctx->out = cl;
348 ctx->last_out = &cl->next;
349
354 r->connection->buffered |= NGX_HTTP_GZIP_BUFFERED; 350 r->connection->buffered |= NGX_HTTP_GZIP_BUFFERED;
355
356 ctx->last_out = &ctx->out;
357 351
358 ctx->crc32 = crc32(0L, Z_NULL, 0); 352 ctx->crc32 = crc32(0L, Z_NULL, 0);
359 ctx->flush = Z_NO_FLUSH; 353 ctx->flush = Z_NO_FLUSH;
360 } 354 }
361 355