request hangs

magz nginx-forum at nginx.us
Mon Feb 28 09:33:55 MSK 2011


magz Wrote:
-------------------------------------------------------
> Hi,
> 
> I have strange problem with main request  hand if
> I call for sub-request.  Maybe somebody can help
> me with it?
> 
> I do spam filtering in post request. So I added
> location to nginx.conf and call sub-request for
> that location. Then read output from sub-request 
> and set up nginx variable according to output.
> 
> So config looks like:
>             location = /checkspam {
>                     internal;
>                     include spam_fastcgi.conf;
>             }
> 
> 
> SOURCE code is here:
> http://codepaste.net/17tfmu
> 
> From client side it looks like client can not
> receive last chank of original request (last 10-50
> bytes). And it's not easy to understand what is
> going on.  Any advises are welcome. 
> 
> I put debug log here:
> http://codepaste.net/ceiian
> 
> Thanks,
> Max.


Silence here means that question was not clear or nobody knows the
answer. I will try to ask my question in another way.  If you know the
answer please respond to me.

I do:
1. register handler in REWRITE_PHASE
h = ngx_array_push(&cmcf->phases[NGX_HTTP_REWRITE_PHASE].handlers);
 *h = ngx_http_form_input_handler;

2.   In ngx_http_form_input_handler() read POST body and act the
handler:
r->request_body_in_single_buf = 1;
rc = ngx_http_read_client_request_body(r,
ngx_http_form_input_post_read);

3. In  ngx_http_form_input_post_read() call subsequent with POST body to
different location
psr->handler = ngx_http_form_input_post_subrequest_handler;
rc = ngx_http_subrequest(r, &uri, &args, &sr, psr, 0);


Now the question is why original request hands on returning last buffer
chank to client?

It looks like client holds on read() forever. If  kill signal is sent to
nginx client receives this last buffer. Also sub-request works fine
(send all POST data from client and receives  what is should receive).
Without sub-request everything works fine too.

Is it know nginx issue? 

What workaround can be applied here? Maybe create create additional
filter and terminate request? Or adjust request buffers after
sub-request is done?

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,178511,179019#msg-179019




More information about the nginx mailing list