From ef80a7bba908cb9786bac560f9c3cb390429829b Mon Sep 17 00:00:00 2001 From: Roberto De Ioris Date: Thu, 18 Oct 2012 12:32:02 +0200 Subject: [PATCH] fixed offload to thread --- core/protocol.c | 6 ++++-- core/sendfile.c | 1 + core/uwsgi.c | 4 ++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/core/protocol.c b/core/protocol.c index 590c0eff..944e7077 100644 --- a/core/protocol.c +++ b/core/protocol.c @@ -1911,7 +1911,10 @@ int uwsgi_real_file_serve(struct wsgi_request *wsgi_req, char *real_filename, si // Ok, the file must be transferred from uWSGI if (wsgi_req->socket->can_offload) { - if (!uwsgi_offload_request_do(wsgi_req, real_filename, st->st_size)) goto done; + if (!uwsgi_offload_request_do(wsgi_req, real_filename, st->st_size)) { + wsgi_req->status = -30; + return 0; + } } wsgi_req->sendfile_fd = open(real_filename, O_RDONLY); @@ -1920,7 +1923,6 @@ int uwsgi_real_file_serve(struct wsgi_request *wsgi_req, char *real_filename, si close(wsgi_req->sendfile_fd); } -done: wsgi_req->status = 200; return 0; } diff --git a/core/sendfile.c b/core/sendfile.c index 999e22a7..1bf63202 100644 --- a/core/sendfile.c +++ b/core/sendfile.c @@ -28,6 +28,7 @@ int uwsgi_offload_request_do(struct wsgi_request *wsgi_req, char *filename, size uor.pos = 0; uor.len = len; uor.written = 0; + uor.buf = NULL; uor.prev = NULL; uor.next = NULL; diff --git a/core/uwsgi.c b/core/uwsgi.c index ddbc767c..316f7ea7 100644 --- a/core/uwsgi.c +++ b/core/uwsgi.c @@ -2221,7 +2221,9 @@ int uwsgi_start(void *v_argv) { #endif // users of the --loop option should know what they are doing... really... +#ifndef UWSGI_DEBUG if (uwsgi.loop) goto unsafe; +#endif #ifdef UWSGI_UDP if (!uwsgi.sockets && !ushared->gateways_cnt && !uwsgi.no_server && !uwsgi.udp_socket && !uwsgi.emperor && !uwsgi.command_mode) { @@ -2246,7 +2248,9 @@ int uwsgi_start(void *v_argv) { uwsgi.to_hell = 1; } +#ifndef UWSGI_DEBUG unsafe: +#endif #ifdef UWSGI_DEBUG struct uwsgi_socket *uwsgi_sock = uwsgi.sockets;