Welcome! Log In Create A New Profile

Advanced

Output body buffer chain "flattening" doesn't work unless proxy buffering is off

Srebrenko Šehić
June 04, 2010 05:58PM
Hi list,

While working on an output body filter, I've noticed that if I flatten
(join all buffers from a chain into 1 buffer), response processing
hangs when nginx decides to start buffering the response from the
upstream server. This usually happens (in my case) when the upstream
response size is >64k. If I set "proxy_buffering" to "off" in my
config, everything works just fine.

Following code snippet illustrates what I'm trying to do (simplified
for brevity):

ngx_uint_t bsize, size;
ngx_chain_t *cl;
ngx_buf_t *b;

for (cl = in; cl; cl = cl->next) {
size += ngx_buf_size(cl->buf);
}

if (size == 0) {
return NGX_DONE;
}

b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));
p = ngx_pcalloc(r->pool, size);

b->pos = p;
b->memory = 1;
b->last = b->pos + size;

for (cl = ctx->in; cl; cl = cl->next) {
bsize = ngx_buf_size(cl->buf);
ngx_memcpy(p + offset, cl->buf->pos, bsize);
offset += bsize;
}

in->buf = b;
in->next = NULL;

return ngx_http_next_body_filter(r, in);

Error log shows the following when the response processing hangs:

2010/06/04 23:33:18 [debug] 7689#0: *1 http copy filter: 0 "/test_case_6.html?"
2010/06/04 23:33:23 [debug] 7689#0: *1 http upstream request:
"/test_case_6.html?"
2010/06/04 23:33:23 [debug] 7689#0: *1 http upstream process upstream
2010/06/04 23:33:23 [debug] 7689#0: *1 http output filter "/test_case_6.html?"
2010/06/04 23:33:23 [debug] 7689#0: *1 http copy filter: "/test_case_6.html?"
2010/06/04 23:33:23 [debug] 7689#0: *1 http postpone filter
"/test_case_6.html?" 00000000
2010/06/04 23:33:23 [debug] 7689#0: *1 http copy filter: 0 "/test_case_6.html?"
2010/06/04 23:33:23 [debug] 7689#0: *1 http output filter "/test_case_6.html?"
2010/06/04 23:33:23 [debug] 7689#0: *1 http copy filter: "/test_case_6.html?"
2010/06/04 23:33:23 [debug] 7689#0: *1 http postpone filter
"/test_case_6.html?" 00000000

What I'm doing wrong?

Thanks,
Srebrenko

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Output body buffer chain "flattening" doesn't work unless proxy buffering is off

Srebrenko Šehić 3319 June 04, 2010 05:58PM

Re: Output body buffer chain "flattening" doesn't work unless proxy buffering is off

Srebrenko Šehić 1176 June 04, 2010 06:00PM

Re: Output body buffer chain "flattening" doesn't work unless proxy buffering is off

Maxim Dounin 1098 June 06, 2010 04:58PM

Re: Output body buffer chain "flattening" doesn't work unless proxy buffering is off

Srebrenko Šehić 1003 June 07, 2010 01:30AM

Re: Output body buffer chain "flattening" doesn't work unless proxy buffering is off

Maxim Dounin 1072 June 07, 2010 03:10AM

Re: Output body buffer chain "flattening" doesn't work unless proxy buffering is off

Srebrenko Šehić 1019 June 07, 2010 04:44PM

Re: Output body buffer chain "flattening" doesn't work unless proxy buffering is off

Srebrenko Šehić 949 June 07, 2010 05:00PM

Re: Output body buffer chain "flattening" doesn't work unless proxy buffering is off

Maxim Dounin 1416 June 07, 2010 06:32PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 305
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