diff options
-rw-r--r-- | mod_wsgi.c | 49 |
1 files changed, 33 insertions, 16 deletions
@@ -195,7 +195,7 @@ static apr_status_t apr_os_pipe_put_ex(apr_file_t **file, #define MOD_WSGI_MAJORVERSION_NUMBER 1 #define MOD_WSGI_MINORVERSION_NUMBER 0 -#define MOD_WSGI_VERSION_STRING "1.0c2" +#define MOD_WSGI_VERSION_STRING "1.0c3-TRUNK" #if AP_SERVER_MAJORVERSION_NUMBER < 2 module MODULE_VAR_EXPORT wsgi_module; @@ -817,17 +817,19 @@ static LogObject *newLogObject(request_rec *r, int level) static void Log_dealloc(LogObject *self) { if (self->s) { - if (self->r) { - Py_BEGIN_ALLOW_THREADS - ap_log_rerror(APLOG_MARK, WSGI_LOG_LEVEL(self->level), - self->r, "%s", self->s); - Py_END_ALLOW_THREADS - } - else { - Py_BEGIN_ALLOW_THREADS - ap_log_error(APLOG_MARK, WSGI_LOG_LEVEL(self->level), - wsgi_server, "%s", self->s); - Py_END_ALLOW_THREADS + if (!self->expired) { + if (self->r) { + Py_BEGIN_ALLOW_THREADS + ap_log_rerror(APLOG_MARK, WSGI_LOG_LEVEL(self->level), + self->r, "%s", self->s); + Py_END_ALLOW_THREADS + } + else { + Py_BEGIN_ALLOW_THREADS + ap_log_error(APLOG_MARK, WSGI_LOG_LEVEL(self->level), + wsgi_server, "%s", self->s); + Py_END_ALLOW_THREADS + } } free(self->s); @@ -3661,10 +3663,12 @@ static int wsgi_execute_script(request_rec *r) AdapterObject *adapter = NULL; adapter = newAdapterObject(r); - Py_INCREF(object); - if (adapter) { + PyObject *args = NULL; + + Py_INCREF(object); status = Adapter_run(adapter, object); + Py_DECREF(object); /* * Wipe out references to Apache request object @@ -3676,6 +3680,21 @@ static int wsgi_execute_script(request_rec *r) adapter->r = NULL; adapter->input->r = NULL; + + /* + * Flush any data held within error log object + * and mark it as expired so that it can't be + * used beyond life of the request. We hope that + * this doesn't error, as it will overwrite any + * error from application if it does. + */ + + args = PyTuple_New(0); + object = Log_flush(adapter->log, args); + Py_XDECREF(object); + Py_DECREF(args); + + adapter->log->r = NULL; adapter->log->expired = 1; #if defined(MOD_WSGI_WITH_BUCKETS) @@ -3684,8 +3703,6 @@ static int wsgi_execute_script(request_rec *r) } Py_XDECREF((PyObject *)adapter); - - Py_DECREF(object); } else { Py_BEGIN_ALLOW_THREADS |