On 1/6/2012 4:28 PM, Christian Boos wrote:
Hello Graham,

On 1/5/2012 11:26 PM, Graham Dumpleton wrote:
 > Hi Christian
 >
 > Thanks for looking at this.
 >
 > I am a bit stumped on this one right now.
 >
 > Is not helped that busy with work trying to get a release out before
 > going on overseas trip for few weeks.
 >

So as it doesn't look like you're going to beat me at it in the
coming days, I'll have a look at the bug myself then :-)


Ok, so it's not fully clear *why* this happens, but at least I've
found some hints and a way to make the problem go away...
Patch attached, with clumsy explanations included ;-)

I think it's also safe to apply on Linux, if you'd like to take
that fix.

But maybe it's just that *this* version of Apache (2.2.21) had some
problems on Windows (or it's a non-thread-safe build?!). The next
step would perhaps to rebuild Apache itself in debug mode and have
a look inside those ap_pass_brigade and apr_brigade_cleanup functions...

-- Christian

--
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/modwsgi?hl=en.

# HG changeset patch
# Parent cd6d0ce09f8b947f03ad25c8e9c1618ad803c3f0
Fix Content-Type having random values on Windows.

It seems that the bucket brigade methods are not fully thread-safe. If
we allow the threads to run before `ap_pass_brigade` or before
`apr_brigade_cleanup` in `Adapter_output`, then it seems that the pool
get somehow messed-up, at least for the `r->content_type` which is
allocated there.

Despite the exact reason for the trouble being still somewhat
mysterious, removing the `Py_{BEGIN,END}_ALLOW_THREADS` macros
around those two functions seems to fix the issue.

diff -r cd6d0ce09f8b mod_wsgi.c
--- a/mod_wsgi.c        Mon Jul 26 03:58:37 2010 +0000
+++ b/mod_wsgi.c        Sat Jan 07 00:56:23 2012 +0100
@@ -3306,18 +3306,14 @@
         b = apr_bucket_flush_create(r->connection->bucket_alloc);
         APR_BRIGADE_INSERT_TAIL(self->bb, b);
 
-        Py_BEGIN_ALLOW_THREADS
         rv = ap_pass_brigade(r->output_filters, self->bb);
-        Py_END_ALLOW_THREADS
 
         if (rv != APR_SUCCESS) {
             PyErr_SetString(PyExc_IOError, "failed to write data");
             return 0;
         }
 
-        Py_BEGIN_ALLOW_THREADS
         apr_brigade_cleanup(self->bb);
-        Py_END_ALLOW_THREADS
 #else
         /*
          * In Apache 1.3, the bucket brigade system doesn't exist,

Reply via email to