completed port of the python plugin to the new writing api

This commit is contained in:
Roberto De Ioris
2013-01-20 14:17:54 +01:00
parent 4b3b3f9200
commit 874e8b5621
5 changed files with 33 additions and 7 deletions
+16 -3
View File
@@ -218,7 +218,9 @@ int uwsgi_response_subhandler_pump(struct wsgi_request *wsgi_req) {
goto clear;
}
uwsgi_response_prepare_headers(wsgi_req, sc, 3);
if (uwsgi_response_prepare_headers(wsgi_req, sc, 3)) {
uwsgi_log("unable to prepare response headers\n");
}
PyObject *hhkey, *hhvalue;
#ifdef UWSGI_PYTHON_OLD
@@ -237,12 +239,12 @@ int uwsgi_response_subhandler_pump(struct wsgi_request *wsgi_req) {
for(i=0;i<PyList_Size(hhvalue);i++) {
PyObject *item = PyList_GetItem(hhvalue, i);
if (PyString_Check(item)) {
uwsgi_response_add_header(wsgi_req, k, kl, PyString_AsString(item), PyString_Size(item));
if (uwsgi_response_add_header(wsgi_req, k, kl, PyString_AsString(item), PyString_Size(item))) goto clear;
}
}
}
else if (PyString_Check(hhvalue)) {
uwsgi_response_add_header(wsgi_req, k, kl, PyString_AsString(hhvalue), PyString_Size(hhvalue));
if (uwsgi_response_add_header(wsgi_req, k, kl, PyString_AsString(hhvalue), PyString_Size(hhvalue))) goto clear;
}
}
@@ -252,6 +254,9 @@ int uwsgi_response_subhandler_pump(struct wsgi_request *wsgi_req) {
UWSGI_RELEASE_GIL
uwsgi_response_write_body_do(wsgi_req, PyString_AsString(wsgi_req->async_placeholder), PyString_Size(wsgi_req->async_placeholder));
UWSGI_GET_GIL
uwsgi_py_check_write_errors {
uwsgi_py_write_exception(wsgi_req);
}
goto clear;
}
#ifdef PYTHREE
@@ -263,6 +268,9 @@ int uwsgi_response_subhandler_pump(struct wsgi_request *wsgi_req) {
UWSGI_RELEASE_GIL
uwsgi_response_sendfile_do(wsgi_req, wsgi_req->sendfile_fd, 0, 0);
UWSGI_GET_GIL
uwsgi_py_check_write_errors {
uwsgi_py_write_exception(wsgi_req);
}
goto clear;
}
@@ -301,6 +309,11 @@ int uwsgi_response_subhandler_pump(struct wsgi_request *wsgi_req) {
UWSGI_RELEASE_GIL
uwsgi_response_write_body_do(wsgi_req, PyString_AsString(pychunk), PyString_Size(pychunk));
UWSGI_GET_GIL
uwsgi_py_check_write_errors {
uwsgi_py_write_exception(wsgi_req);
Py_DECREF(pychunk);
goto clear;
}
}
+6 -1
View File
@@ -887,7 +887,6 @@ PyObject *py_uwsgi_advanced_sendfile(PyObject * self, PyObject * args) {
UWSGI_RELEASE_GIL
uwsgi_response_sendfile_do(wsgi_req, wsgi_req->sendfile_fd, wsgi_req->sendfile_fd_pos, wsgi_req->sendfile_fd_size);
UWSGI_GET_GIL
// revert to old values
wsgi_req->sendfile_fd = tmp_fd;
wsgi_req->sendfile_fd_size = tmp_filesize;
@@ -896,6 +895,12 @@ PyObject *py_uwsgi_advanced_sendfile(PyObject * self, PyObject * args) {
close(fd);
uwsgi_py_check_write_errors {
uwsgi_py_write_exception(wsgi_req);
return NULL;
}
Py_INCREF(Py_True);
return Py_True;
+2 -2
View File
@@ -170,7 +170,7 @@ int uwsgi_response_subhandler_web3(struct wsgi_request *wsgi_req) {
char *content = PyString_AsString(wsgi_req->async_placeholder);
size_t content_len = PyString_Size(wsgi_req->async_placeholder);
UWSGI_RELEASE_GIL
wsgi_req->response_size += wsgi_req->socket->proto_write(wsgi_req, content, content_len);
uwsgi_response_write_body_do(wsgi_req, content, content_len);
UWSGI_GET_GIL
uwsgi_py_check_write_errors {
uwsgi_py_write_exception(wsgi_req);
@@ -213,7 +213,7 @@ int uwsgi_response_subhandler_web3(struct wsgi_request *wsgi_req) {
char *content = PyString_AsString(pychunk);
size_t content_len = PyString_Size(pychunk);
UWSGI_RELEASE_GIL
wsgi_req->response_size += wsgi_req->socket->proto_write(wsgi_req, content, content_len);
uwsgi_response_write_body_do(wsgi_req, content, content_len);
UWSGI_GET_GIL
uwsgi_py_check_write_errors {
uwsgi_py_write_exception(wsgi_req);
+1 -1
View File
@@ -498,7 +498,7 @@ int uwsgi_request_wsgi(struct wsgi_request *wsgi_req) {
// LOCK THIS PART
uwsgi_500(wsgi_req);
uwsgi_response_write_headers_do(wsgi_req);
if (uwsgi_response_write_headers_do(wsgi_req)) goto clear;
/*
sorry that is a hack to avoid the rewrite of PyErr_Print
+8
View File
@@ -173,6 +173,9 @@ int uwsgi_response_subhandler_wsgi(struct wsgi_request *wsgi_req) {
UWSGI_RELEASE_GIL
uwsgi_response_sendfile_do(wsgi_req, wsgi_req->sendfile_fd, 0, 0);
UWSGI_GET_GIL
uwsgi_py_check_write_errors {
uwsgi_py_write_exception(wsgi_req);
}
goto clear;
}
@@ -228,6 +231,11 @@ exception:
UWSGI_RELEASE_GIL
uwsgi_response_sendfile_do(wsgi_req, wsgi_req->sendfile_fd, 0, 0);
UWSGI_GET_GIL
uwsgi_py_check_write_errors {
uwsgi_py_write_exception(wsgi_req);
Py_DECREF(pychunk);
goto clear;
}
}