From b15a0a2d4b95cf6e8d32072c04b3cd7945fac117 Mon Sep 17 00:00:00 2001 From: "roberto@precise64" Date: Sat, 5 May 2012 09:30:43 +0200 Subject: [PATCH] added --disable-write-exception --- plugins/python/uwsgi_python.h | 2 +- plugins/python/wsgi_handlers.c | 2 +- plugins/python/wsgi_headers.c | 2 +- uwsgi.c | 1 + uwsgi.h | 1 + 5 files changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/python/uwsgi_python.h b/plugins/python/uwsgi_python.h index 4f189e88..7c8aaac4 100644 --- a/plugins/python/uwsgi_python.h +++ b/plugins/python/uwsgi_python.h @@ -38,7 +38,7 @@ #define PyVarObject_HEAD_INIT(x, y) PyObject_HEAD_INIT(x) y, #endif -#define uwsgi_py_write_set_exception(x) PyErr_SetString(PyExc_IOError, "write error"); +#define uwsgi_py_write_set_exception(x) if (!uwsgi.disable_write_exception) { PyErr_SetString(PyExc_IOError, "write error"); }; #define uwsgi_py_write_exception(x) uwsgi_py_write_set_exception(x); PyErr_Print(); diff --git a/plugins/python/wsgi_handlers.c b/plugins/python/wsgi_handlers.c index 659fc430..647dcbd2 100644 --- a/plugins/python/wsgi_handlers.c +++ b/plugins/python/wsgi_handlers.c @@ -285,7 +285,7 @@ PyObject *py_uwsgi_write(PyObject * self, PyObject * args) { UWSGI_GET_GIL // this is a special case for the write callable // no need to honout write-errors-exception-only - if (wsgi_req->write_errors > uwsgi.write_errors_tolerance) { + if (wsgi_req->write_errors > uwsgi.write_errors_tolerance && !uwsgi.disable_write_exception) { uwsgi_py_write_set_exception(wsgi_req); return NULL; } diff --git a/plugins/python/wsgi_headers.c b/plugins/python/wsgi_headers.c index 51765686..93aadf73 100644 --- a/plugins/python/wsgi_headers.c +++ b/plugins/python/wsgi_headers.c @@ -258,7 +258,7 @@ int uwsgi_python_do_send_headers(struct wsgi_request *wsgi_req) { wsgi_req->headers_sent = 1; - if (wsgi_req->write_errors > uwsgi.write_errors_tolerance) { + if (wsgi_req->write_errors > uwsgi.write_errors_tolerance && !uwsgi.disable_write_exception) { uwsgi_py_write_set_exception(wsgi_req); return -1; } diff --git a/uwsgi.c b/uwsgi.c index 7029403a..5b8174fe 100644 --- a/uwsgi.c +++ b/uwsgi.c @@ -92,6 +92,7 @@ static struct uwsgi_option uwsgi_base_options[] = { {"ignore-write-errors", no_argument, 0, "do not report (annoying) write()/writev() errors", uwsgi_opt_true, &uwsgi.ignore_write_errors,0}, {"write-errors-tolerance", required_argument, 0, "set the maximum number of allowed write errors (default: no tolerance)", uwsgi_opt_set_int, &uwsgi.write_errors_tolerance,0}, {"write-errors-exception-only", no_argument, 0, "only raise an exception on write errors giving control to the app itself", uwsgi_opt_true, &uwsgi.write_errors_exception_only,0}, + {"disable-write-exception", no_argument, 0, "disable exception generation on write()/writev()", uwsgi_opt_true, &uwsgi.disable_write_exception,0}, {"inherit", required_argument, 0, "use the specified file as config template", uwsgi_opt_load, NULL,0}, {"daemonize", required_argument, 'd', "daemonize uWSGI", uwsgi_opt_set_str, &uwsgi.daemonize, 0}, diff --git a/uwsgi.h b/uwsgi.h index b166e459..85fcdb1d 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -1203,6 +1203,7 @@ struct uwsgi_server { int ignore_write_errors; int write_errors_tolerance; int write_errors_exception_only; + int disable_write_exception; // still working on it char *profiler;