If a client goes away while mod_wsgi is writing (causing ap_pass_brigate to
fail), it currently raises an IOError, which causes an entry in Apache's
error log. There is some code that tries to detect disconnects and
optionally log a debug statement instead, but it doesn't work very well.
Additionally, if the client goes away during a write, the ap_bucket_brigade
is never cleaned up.
I believe that the attached patch will resolve both issues.
--
You received this message because you are subscribed to the Google Groups
"modwsgi" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/modwsgi/-/8rrFFT2NNNQJ.
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.
--- mod_wsgi~/mod_wsgi.c 2012-04-19 12:12:43.000000000 -0700
+++ mod_wsgi/mod_wsgi.c 2012-04-19 12:15:28.012541540 -0700
@@ -3311,7 +3311,16 @@
Py_END_ALLOW_THREADS
if (rv != APR_SUCCESS) {
- PyErr_SetString(PyExc_IOError, "failed to write data");
+ Py_BEGIN_ALLOW_THREADS
+ apr_brigade_cleanup(self->bb);
+ Py_END_ALLOW_THREADS
+ if (!exception_when_aborted) {
+ ap_log_rerror(APLOG_MARK, WSGI_LOG_DEBUG(0), r,
+ "mod_wsgi (pid=%d): failed to write data (client closed connection?).",
+ getpid());
+ }
+ else
+ PyErr_SetString(PyExc_IOError, "failed to write data");
return 0;
}
@@ -3331,7 +3340,13 @@
Py_END_ALLOW_THREADS
if (n == -1) {
- PyErr_SetString(PyExc_IOError, "failed to write data");
+ if (!exception_when_aborted) {
+ ap_log_rerror(APLOG_MARK, WSGI_LOG_DEBUG(0), r,
+ "mod_wsgi (pid=%d): failed to write data (client closed connection?).",
+ getpid());
+ }
+ else
+ PyErr_SetString(PyExc_IOError, "failed to write data");
return 0;
}