summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGraham.Dumpleton <devnull@localhost>2007-08-12 04:51:49 +0000
committerGraham.Dumpleton <devnull@localhost>2007-08-12 04:51:49 +0000
commitc70991b9059ff1902e639ae2979564e9fa8d5c46 (patch)
treee2ae617cda4948845bbf5a14a4264b070244c76e
parentc454b0cd2b881c7de591d5e5884d01b381ea303b (diff)
downloadmod_wsgi-c70991b9059ff1902e639ae2979564e9fa8d5c46.tar.gz
Flush wsgi.errors at end of request and ignore any residual in log buffers
when deleting log object associated with a request. This is to eliminate segmentation fault if there was any buffered data when deleting log object. Don't just write residual request error log data to server log as that may be different to request error log and don't want to cause confusion by it ending up where it shouldn't.
-rw-r--r--mod_wsgi.c49
1 files changed, 33 insertions, 16 deletions
diff --git a/mod_wsgi.c b/mod_wsgi.c
index c1ea52f..d85bbc1 100644
--- a/mod_wsgi.c
+++ b/mod_wsgi.c
@@ -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