Mercurial > hg > ngx_http_bytes_filter_module
comparison ngx_http_bytes_filter_module.c @ 17:314242bda1c1
Correctly handle last ignored buffer again.
If we ignore buffer marked as last_buf, make sure we pass out empty buffer
marked as last_buf. The same problem was already fixed in rev. 48cdd1bfa48e,
but only for optimized special case (last range and last buffer).
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 02 Feb 2009 19:54:12 +0300 |
parents | 2a8b38acb895 |
children | c3bd9d8ab52a |
comparison
equal
deleted
inserted
replaced
16:d1f754919b5d | 17:314242bda1c1 |
---|---|
397 for (ll = &out, cl = in; cl; cl = cl->next, ctx->offset += size) { | 397 for (ll = &out, cl = in; cl; cl = cl->next, ctx->offset += size) { |
398 | 398 |
399 buf = cl->buf; | 399 buf = cl->buf; |
400 size = ngx_buf_size(buf); | 400 size = ngx_buf_size(buf); |
401 | 401 |
402 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 402 ngx_log_debug5(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
403 "bytes body filter: b %O, offset %O, range %O-%O", | 403 "bytes body filter: b %O, l %d, offset %O, range %O-%O", |
404 size, ctx->offset, range->start, range->end); | 404 size, buf->last_buf, ctx->offset, |
405 range->start, range->end); | |
405 | 406 |
406 if (ngx_buf_special(buf)) { | 407 if (ngx_buf_special(buf)) { |
407 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 408 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
408 "bytes body filter: special buffer"); | 409 "bytes body filter: special buffer"); |
409 | 410 |
423 } | 424 } |
424 | 425 |
425 if (range->start > ctx->offset + size || range->end < ctx->offset) { | 426 if (range->start > ctx->offset + size || range->end < ctx->offset) { |
426 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 427 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
427 "bytes body filter: fully ignored buffer"); | 428 "bytes body filter: fully ignored buffer"); |
429 | |
428 buf->pos = buf->last; | 430 buf->pos = buf->last; |
431 | |
432 if (!buf->last_buf) { | |
433 continue; | |
434 } | |
435 | |
436 /* for last buffer, make sure we pass out empty one */ | |
437 | |
438 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
439 "bytes body filter: last buffer ignored"); | |
440 | |
441 dcl = ngx_alloc_chain_link(r->pool); | |
442 if (dcl == NULL) { | |
443 return NGX_ERROR; | |
444 } | |
445 | |
446 b = ngx_calloc_buf(r->pool); | |
447 if (b == NULL) { | |
448 return NGX_ERROR; | |
449 } | |
450 | |
451 b->last_buf = 1; | |
452 | |
453 *ll = dcl; | |
454 dcl->buf = b; | |
455 dcl->next = NULL; | |
456 ll = &dcl->next; | |
457 | |
429 continue; | 458 continue; |
430 } | 459 } |
431 | 460 |
432 next: | 461 next: |
433 /* we should either free or reuse original buffer */ | 462 /* we should either free or reuse original buffer */ |