From 7dc059c75bdd7ef3d7dd1f0df2c2af25ce917767 Mon Sep 17 00:00:00 2001 From: "roberto@freebsd64" Date: Wed, 5 Oct 2011 20:34:25 +0200 Subject: [PATCH] completed new freebsd64 sendfiel async support --- plugins/python/wsgi_subhandler.c | 4 ++++ sendfile.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/python/wsgi_subhandler.c b/plugins/python/wsgi_subhandler.c index cce67afc..a9475260 100644 --- a/plugins/python/wsgi_subhandler.c +++ b/plugins/python/wsgi_subhandler.c @@ -194,7 +194,11 @@ int uwsgi_response_subhandler_wsgi(struct wsgi_request *wsgi_req) { #ifdef UWSGI_SENDFILE +#ifdef __FreeBSD__ + if ( ((wsgi_req->sendfile_obj == wsgi_req->async_result) || ( wsgi_req->sendfile_fd_size > 0 && wsgi_req->response_size < wsgi_req->sendfile_fd_size)) && wsgi_req->sendfile_fd != -1) { +#else if (wsgi_req->sendfile_obj == wsgi_req->async_result && wsgi_req->sendfile_fd != -1) { +#endif sf_len = uwsgi_sendfile(wsgi_req); if (sf_len < 1) goto clear; wsgi_req->response_size += sf_len; diff --git a/sendfile.c b/sendfile.c index c44ffd14..b869836a 100644 --- a/sendfile.c +++ b/sendfile.c @@ -56,7 +56,7 @@ ssize_t uwsgi_do_sendfile(int sockfd, int filefd, size_t filesize, size_t chunk, sf_ret = sendfile(filefd, sockfd, 0, 0, NULL, &sf_len, 0); } - if (sf_ret) { + if (sf_ret < 0) { if (errno != EAGAIN) { uwsgi_error("sendfile()"); return 0;