| Issue 132: | Truncated response with using wsgi.file_wrapper when data > 255 and < ~8000. | |
| 4 people starred this issue and may be notified of changes. | Back to list |
Per discussion in: http://groups.google.com/group/modwsgi/browse_frm/thread/e7111816e70d236a Apache implements an optimisation when keep alive is requested, which results in file buckets referencing a file containing > 255 and < ~8000 bytes, not being immediately flushed out but held over to when request actually ends or subsequent request on same connection occurs. This causes problems for mod_wsgi as the file descriptor wrapped by wsgi.file_wrapper could have been closed by the time that Apache tries to use it. The end result is a completely empty response and an error on the Apache error logs (but only if LogLevel is debug) of: (9)Bad file descriptor: core_output_filter: writing data to the network The affected code in mod_wsgi is in Adapter_output_file(): APR_BRIGADE_INSERT_TAIL(bb, b); b = apr_bucket_eos_create(r->connection->bucket_alloc); APR_BRIGADE_INSERT_TAIL(bb, b); Py_BEGIN_ALLOW_THREADS rv = ap_pass_brigade(r->output_filters, bb); Py_END_ALLOW_THREADS As the optimisation only occurs in Apache when EOS bucket is detected immediately after the file bucket, fix is to insert a flush bucket. APR_BRIGADE_INSERT_TAIL(bb, b); b = apr_bucket_flush_create(r->connection->bucket_alloc); APR_BRIGADE_INSERT_TAIL(bb, b); b = apr_bucket_eos_create(r->connection->bucket_alloc); APR_BRIGADE_INSERT_TAIL(bb, b); Py_BEGIN_ALLOW_THREADS rv = ap_pass_brigade(r->output_filters, bb); Py_END_ALLOW_THREADS
Feb 14, 2009
Project Member
#1
Graham.Dumpleton@gmail.com
Status:
Started
Feb 14, 2009
Also backport to 2.X branch for 2.4 at revision 1199.
Labels:
-Milestone-Release3.0 Milestone-Release2.4
Apr 11, 2009
Version 2.4 of mod_wsgi now released.
Status:
Fixed
Apr 14, 2009
If cannot upgrade, disabling KeepAlive in Apache should prevent this problem from occurring as Apache optimisation only applied in that situation.
May 14, 2009
Note that this issue should only by rights apply to UNIX systems and shouldn't occur on Windows as file optimisation not done on Windows. |
|
| ► Sign in to add a comment |