[dev] possible "bug" in ngx_http_read_discarded_body_handler

Manlio Perillo manlio_perillo at libero.it
Wed Oct 3 19:11:53 MSD 2007


Igor Sysoev ha scritto:
> On Mon, Oct 01, 2007 at 08:46:56PM +0200, Manlio Perillo wrote:
> 
>> I'm reading the ngx_http_request_body source file version 0.5.31, and I 
>> have found a possible "bug":
>>
>>
>> static void
>> ngx_http_read_discarded_body_handler(ngx_http_request_t *r)
>> {
>>     ngx_int_t  rc;
>>
>>     rc = ngx_http_read_discarded_body(r);
>>
>>     if (rc == NGX_AGAIN) {
>>         if (ngx_handle_read_event(r->connection->read, 0) == NGX_ERROR) 
>>    {
>>             ngx_http_finalize_request(r, rc);
>>             return;
>>         }
>>     }
>>
>>
>> I think that the code should be:
>>
>>     if (rc == NGX_AGAIN) {
>>         if (ngx_handle_read_event(r->connection->read, 0) == NGX_ERROR) 
>>    {
>>             ngx_http_finalize_request(r, NGX_ERROR);
>>             return;
>>         }
>>     }
>>
>>
>> If I'm wrong, then I do not understand why to finalize with NGX_AGAIN.
> 
> Yes, you right. Fortunatly, ngx_handle_read_event() should never fail,
> only if something wrong in kernel.
> 

I have read the ngx_http_finalize_request source and it handles the 
NGX_AGAIN status code.

Its very hard to follow the entire code flow of Nginx!


Regards  Manlio Perillo





More information about the nginx mailing list