From 8887f83f7f4535c80feb05bc181708d6f9971685 Mon Sep 17 00:00:00 2001 From: Unbit Date: Sat, 13 Jul 2013 17:26:43 +0200 Subject: [PATCH] use the right sendfile abstraction --- core/sendfile.c | 4 ++++ plugins/router_static/router_static.c | 5 +---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/core/sendfile.c b/core/sendfile.c index 606832c1..9e4529f4 100644 --- a/core/sendfile.c +++ b/core/sendfile.c @@ -71,5 +71,9 @@ int uwsgi_simple_sendfile(struct wsgi_request *wsgi_req, int fd, size_t pos, siz return -1; } } + + wsgi_req->response_size += wsgi_req->write_pos; + // reset for the next write + wsgi_req->write_pos = 0; return 0; } diff --git a/plugins/router_static/router_static.c b/plugins/router_static/router_static.c index ad3c072b..c09616a2 100644 --- a/plugins/router_static/router_static.c +++ b/plugins/router_static/router_static.c @@ -141,10 +141,7 @@ int uwsgi_routing_func_sendfile(struct wsgi_request *wsgi_req, struct uwsgi_rout if (uwsgi_response_add_content_type(wsgi_req, urfc->content_type, urfc->content_type_len)) goto end2; } - ssize_t rlen = uwsgi_sendfile_do(wsgi_req->fd, fd, 0, st.st_size); - if (rlen > 0) { - wsgi_req->response_size += rlen; - } + uwsgi_simple_sendfile(wsgi_req, fd, 0, st.st_size); end2: close(fd);