Simon Liu
September 14, 2010 11:04PM
my nginx version is 0.7.67.

I test nginx's sub filter, there have some alert log in error log:

*the http output chain is empty while sending response to client.*
*
*
and i debug nginx , and then found this is cause by sub filter. so i read
sub filter's source.

in ngx_http_sub_body_filter:

* if (ctx->once && (ctx->buf == NULL || ctx->in == NULL)) {*
*
*
* if (ctx->busy) {*
* if (ngx_http_sub_output(r, ctx) == NGX_ERROR) {*
* return NGX_ERROR;*
* }*
* }*
*
*
* return ngx_http_next_body_filter(r, in);*
* }*

i found when sub_filter_once is on , after text have replaced . and the
second enter ngx_http_sub_body_filter.
At the moment when in is null,ctx->busy is not null,and so *ngx_http_sub_output
may send *the rest of* buf completely**, therefore in
**ngx_http_next_body_filter
will log alert log : the http output chain is empty while sending response
to client. *
*
*
*i*n conclusion I *think there should add a *judgement that in is whether
or not NULL.
*
*
*this is my patch:*
*
*
*
--- nginx-0.7.67/src/http/modules/ngx_http_sub_filter_module.c 2009-10-26
23:54:29.000000000 +0800
+++ nginx-0.7.67_new/src/http/modules/ngx_http_sub_filter_module.c 2010-09-15
10:14:04.996666685 +0800
@@ -187,16 +187,16 @@ ngx_http_sub_body_filter(ngx_http_reques
}

if (ctx->once && (ctx->buf == NULL || ctx->in == NULL)) {

if (ctx->busy) {
- if (ngx_http_sub_output(r, ctx) == NGX_ERROR) {
- return NGX_ERROR;
- }
+ rc = ngx_http_sub_output(r, ctx);
}

- return ngx_http_next_body_filter(r, in);
+ if (rc != NGX_ERROR && in != NULL)
+ return ngx_http_next_body_filter(r, in);
+ return rc;
}

/* add the incoming chain to the chain ctx->in */

if (in) {
*
*
*
--
博观约取

豆瓣:www.douban.com/people/mustang/

blog: www.pagefault.info

twitter: www.twitter.com/minibobo
_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

sub filter‘s bug?

Simon Liu September 14, 2010 11:04PM

Re: sub filter‘s bug?

Simon Liu September 21, 2010 05:14AM

Re: sub filter‘s bug?

Maxim Dounin September 21, 2010 08:06AM

Re: sub filter‘s bug?

Simon Liu September 21, 2010 08:40AM

Re: sub filter‘s bug?

Maxim Dounin September 21, 2010 10:38AM

Re: sub filter‘s bug?

Simon Liu September 21, 2010 11:16AM

Re: sub filter‘s bug?

Simon Liu September 23, 2010 11:24PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 133
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready