added --write-errors-tolerance and --write-errors-exception-only

This commit is contained in:
roberto@precise64
2012-04-14 09:11:52 +02:00
parent d934270a27
commit b7e6da3392
9 changed files with 57 additions and 5 deletions
+6
View File
@@ -41,6 +41,12 @@
#define uwsgi_py_write_set_exception(x) PyErr_SetString(PyExc_IOError, "write error");
#define uwsgi_py_write_exception(x) uwsgi_py_write_set_exception(x); PyErr_Print();
#define uwsgi_py_check_write_errors if (wsgi_req->write_errors > 0 && uwsgi.write_errors_exception_only) {\
uwsgi_py_write_set_exception(wsgi_req);\
}\
else if (wsgi_req->write_errors > uwsgi.write_errors_tolerance)\
PyAPI_FUNC(PyObject *) PyMarshal_WriteObjectToString(PyObject *, int);
PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(char *, Py_ssize_t);
+2 -2
View File
@@ -172,7 +172,7 @@ int uwsgi_response_subhandler_web3(struct wsgi_request *wsgi_req) {
UWSGI_RELEASE_GIL
wsgi_req->response_size += wsgi_req->socket->proto_write(wsgi_req, content, content_len);
UWSGI_GET_GIL
if (wsgi_req->write_errors > 0) {
uwsgi_py_check_write_errors {
uwsgi_py_write_exception(wsgi_req);
}
goto clear;
@@ -215,7 +215,7 @@ int uwsgi_response_subhandler_web3(struct wsgi_request *wsgi_req) {
UWSGI_RELEASE_GIL
wsgi_req->response_size += wsgi_req->socket->proto_write(wsgi_req, content, content_len);
UWSGI_GET_GIL
if (wsgi_req->write_errors > 0) {
uwsgi_py_check_write_errors {
uwsgi_py_write_exception(wsgi_req);
Py_DECREF(pychunk);
goto clear;
+2
View File
@@ -278,6 +278,8 @@ PyObject *py_uwsgi_write(PyObject * self, PyObject * args) {
UWSGI_RELEASE_GIL
wsgi_req->response_size = wsgi_req->socket->proto_write(wsgi_req, content, len);
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 > 0) {
uwsgi_py_write_set_exception(wsgi_req);
return NULL;
+2 -2
View File
@@ -169,7 +169,7 @@ int uwsgi_response_subhandler_wsgi(struct wsgi_request *wsgi_req) {
UWSGI_RELEASE_GIL
wsgi_req->response_size += wsgi_req->socket->proto_write(wsgi_req, content, content_len);
UWSGI_GET_GIL
if (wsgi_req->write_errors > 0) {
uwsgi_py_check_write_errors {
uwsgi_py_write_exception(wsgi_req);
}
goto clear;
@@ -255,7 +255,7 @@ int uwsgi_response_subhandler_wsgi(struct wsgi_request *wsgi_req) {
UWSGI_RELEASE_GIL
wsgi_req->response_size += wsgi_req->socket->proto_write(wsgi_req, content, content_len);
UWSGI_GET_GIL
if (wsgi_req->write_errors > 0) {
uwsgi_py_check_write_errors {
uwsgi_py_write_exception(wsgi_req);
Py_DECREF(pychunk);
goto clear;