first destructive commit for uWSGI 0.9.8

This commit is contained in:
roberto@natty32
2011-04-16 19:41:58 +02:00
parent 1400a95cec
commit 09ee97e775
21 changed files with 724 additions and 229 deletions
+2 -2
View File
@@ -397,7 +397,7 @@ PyObject *py_uwsgi_rpc(PyObject * self, PyObject * args) {
if (rlen > 0) {
upoll.fd = fd;
upoll.events = POLLIN;
if (uwsgi_parse_response(&upoll, uwsgi.shared->options[UWSGI_OPTION_SOCKET_TIMEOUT], &uh, buffer)) {
if (uwsgi_parse_response(&upoll, uwsgi.shared->options[UWSGI_OPTION_SOCKET_TIMEOUT], &uh, buffer, uwsgi_proto_uwsgi_parser)) {
size = uh.pktsize;
}
}
@@ -1353,7 +1353,7 @@ PyObject *py_uwsgi_send_multi_message(PyObject * self, PyObject * args) {
else {
for (i = 0; i < clen; i++) {
if (multipoll[i].revents & POLLIN) {
if (!uwsgi_parse_response(&multipoll[i], PyInt_AsLong(arg_timeout), &uh, &buffer[i])) {
if (!uwsgi_parse_response(&multipoll[i], PyInt_AsLong(arg_timeout), &uh, &buffer[i], uwsgi_proto_uwsgi_parser)) {
goto megamulticlear;
}
else {
+32 -28
View File
@@ -171,7 +171,7 @@ PyObject *py_uwsgi_write(PyObject * self, PyObject * args) {
content = PyString_AsString(data);
len = PyString_Size(data);
UWSGI_RELEASE_GIL
wsgi_req->response_size = write(wsgi_req->poll.fd, content, len);
wsgi_req->response_size = wsgi_req->socket_proto_write(wsgi_req, content, len);
UWSGI_GET_GIL
}
@@ -354,6 +354,7 @@ int uwsgi_request_wsgi(struct wsgi_request *wsgi_req) {
goto clear;
}
if (strncmp(wsgi_req->protocol, "HTTP/", 5)) {
uwsgi_log( "INVALID PROTOCOL: %.*s\n", wsgi_req->protocol_len, wsgi_req->protocol);
internal_server_error(wsgi_req->poll.fd, "invalid HTTP protocol !!!");
@@ -410,37 +411,40 @@ int uwsgi_request_wsgi(struct wsgi_request *wsgi_req) {
if (uwsgi.post_buffering > 0) {
UWSGI_RELEASE_GIL
// read to disk if post_cl > post_buffering
if (!up.pep3333_input) {
if (wsgi_req->post_cl >= (size_t) uwsgi.post_buffering) {
if (!uwsgi_read_whole_body(wsgi_req, wsgi_req->post_buffering_buf, uwsgi.post_buffering_bufsize)) {
goto clear;
// some protocol (http included) pass the body directly as a FILE object
if (!wsgi_req->async_post) {
if (uwsgi.post_buffering > 0) {
UWSGI_RELEASE_GIL
// read to disk if post_cl > post_buffering
if (!up.pep3333_input) {
if (wsgi_req->post_cl >= (size_t) uwsgi.post_buffering) {
if (!uwsgi_read_whole_body(wsgi_req, wsgi_req->post_buffering_buf, uwsgi.post_buffering_bufsize)) {
goto clear;
}
}
else {
wsgi_req->async_post = fdopen(wsgi_req->poll.fd, "r");
}
}
else {
wsgi_req->async_post = fdopen(wsgi_req->poll.fd, "r");
// read to disk if post_cl > post_buffering
if (wsgi_req->post_cl >= (size_t) uwsgi.post_buffering) {
if (!uwsgi_read_whole_body(wsgi_req, wsgi_req->post_buffering_buf, uwsgi.post_buffering_bufsize)) {
goto clear;
}
}
// on tiny post use memory
else {
if (!uwsgi_read_whole_body_in_mem(wsgi_req, wsgi_req->post_buffering_buf)) {
goto clear;
}
}
}
UWSGI_GET_GIL
}
else {
// read to disk if post_cl > post_buffering
if (wsgi_req->post_cl >= (size_t) uwsgi.post_buffering) {
if (!uwsgi_read_whole_body(wsgi_req, wsgi_req->post_buffering_buf, uwsgi.post_buffering_bufsize)) {
goto clear;
}
}
// on tiny post use memory
else {
if (!uwsgi_read_whole_body_in_mem(wsgi_req, wsgi_req->post_buffering_buf)) {
goto clear;
}
}
wsgi_req->async_post = fdopen(wsgi_req->poll.fd, "r");
}
UWSGI_GET_GIL
}
else {
wsgi_req->async_post = fdopen(wsgi_req->poll.fd, "r");
}
if (!up.pep3333_input) {
@@ -488,9 +492,9 @@ int uwsgi_request_wsgi(struct wsgi_request *wsgi_req) {
// LOCK THIS PART
wsgi_req->response_size += write(wsgi_req->poll.fd, wsgi_req->protocol, wsgi_req->protocol_len);
wsgi_req->response_size += write(wsgi_req->poll.fd, " 500 Internal Server Error\r\n", 28 );
wsgi_req->response_size += write(wsgi_req->poll.fd, "Content-type: text/plain\r\n\r\n", 28 );
wsgi_req->response_size += wsgi_req->socket_proto_write(wsgi_req, wsgi_req->protocol, wsgi_req->protocol_len);
wsgi_req->response_size += wsgi_req->socket_proto_write(wsgi_req, " 500 Internal Server Error\r\n", 28 );
wsgi_req->response_size += wsgi_req->socket_proto_write(wsgi_req, "Content-type: text/plain\r\n\r\n", 28 );
wsgi_req->header_cnt = 1;
/*
+1 -1
View File
@@ -176,7 +176,7 @@ PyObject *py_uwsgi_spit(PyObject * self, PyObject * args) {
uh.pktsize += wsgi_req->hvec[j].iov_len;
UWSGI_RELEASE_GIL
wsgi_req->headers_size = writev(wsgi_req->poll.fd, wsgi_req->hvec, j + 1);
wsgi_req->headers_size = wsgi_req->socket_proto_writev(wsgi_req, wsgi_req->hvec, j + 1);
UWSGI_GET_GIL
if (wsgi_req->headers_size < 0) {
uwsgi_error("writev()");
+3 -3
View File
@@ -124,7 +124,7 @@ int uwsgi_response_subhandler_wsgi(struct wsgi_request *wsgi_req) {
// return or yield ?
if (PyString_Check((PyObject *)wsgi_req->async_result)) {
if ((wsize = write(wsgi_req->poll.fd, PyString_AsString(wsgi_req->async_result), PyString_Size(wsgi_req->async_result))) < 0) {
if ((wsize = wsgi_req->socket_proto_write(wsgi_req, PyString_AsString(wsgi_req->async_result), PyString_Size(wsgi_req->async_result))) < 0) {
uwsgi_error("write()");
goto clear;
}
@@ -185,7 +185,7 @@ int uwsgi_response_subhandler_wsgi(struct wsgi_request *wsgi_req) {
if (PyString_Check(pychunk)) {
if ((wsize = write(wsgi_req->poll.fd, PyString_AsString(pychunk), PyString_Size(pychunk))) < 0) {
if ((wsize = wsgi_req->socket_proto_write(wsgi_req, PyString_AsString(pychunk), PyString_Size(pychunk))) < 0) {
uwsgi_error("write()");
Py_DECREF(pychunk);
goto clear;
@@ -216,7 +216,7 @@ clear:
}
if (wsgi_req->async_post && !wsgi_req->fd_closed) {
fclose(wsgi_req->async_post);
if (!uwsgi.post_buffering || wsgi_req->post_cl <= (size_t) uwsgi.post_buffering) {
if ( (!uwsgi.post_buffering || wsgi_req->post_cl <= (size_t) uwsgi.post_buffering) && !wsgi_req->body_as_file) {
wsgi_req->fd_closed = 1;
}
}