[dev] buffer chain and NGX_AGAIN

Manlio Perillo manlio_perillo at libero.it
Fri Oct 5 16:04:15 MSD 2007


Manlio Perillo ha scritto:
> Manlio Perillo ha scritto:
>> Hi.
>>
>> I have another question about buffer chains and NGX_AGAIN.
>>
>> Suppose that ngx_http_output_filter returns NGX_AGAIN and I set the 
>> events to be notified when I can send further data.
>>
>> When my handler is called again, has the previous buffer been sent to 
>> the client or copied in one of the output filter chains?
>>
>> This is important because in mod_wsgi the buffer points to a Python 
>> object and I must know when I can safely deallocate it.
>>
> 
> I have done some tests, and, unfortunately, when the write handler is 
> called (after a NGX_AGAIN), the previous buffer is still in use, so I 
> can't free it.
> 

I think I have found a good solution, but I would like a confirmation.

Instead to store the last used Python object buffer in the context, I 
will store a list.

When ngx_http_output_filter returns NGX_AGAIN, I push the Python object 
in the list.
When ngx_http_output_filter return NGX_OK, I pop a Python object from 
the list and free it.

To be sure to free all the objects, I will add a ngx_pool_cleanup_t 
handler that will free all the remaing items (assuming that the HTTP 
context for mod_wsgi is still "in scope").

 > [...]


Thanks and regards  Manlio Perillo





More information about the nginx mailing list