Hi cgit is too fast for epoll, causing epoll to send a hangup event even though there are still several kilobytes left to read.
With this change, cgit can correctly send huge files on monkey. - Lauri
>From 6a6dc3b07e8678d075b8f24fabd4e3239a961956 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <[email protected]> Date: Sun, 16 Dec 2012 17:10:11 +0200 Subject: [PATCH 2/3] cgi: Fix behavior with high-performance CGI cgit is too fast for epoll, causing epoll to send a hangup event even though there are still several kilobytes left to read. With this change, cgit can correctly send huge files on monkey. Signed-off-by: Lauri Kasanen <[email protected]> --- plugins/cgi/event.c | 24 ++++++++++++++++++++++-- 1 files changed, 22 insertions(+), 2 deletions(-) diff --git a/plugins/cgi/event.c b/plugins/cgi/event.c index 0c0f015..7390e80 100644 --- a/plugins/cgi/event.c +++ b/plugins/cgi/event.c @@ -20,8 +20,8 @@ #include "cgi.h" -static int hangup(int socket) -{ +static void done(const int socket) { + struct cgi_request *r = cgi_req_get_by_fd(socket); if (r) { @@ -43,6 +43,26 @@ static int hangup(int socket) requests_by_socket[r->socket] = NULL; cgi_req_del(r); + } +} + +static int hangup(const int socket) +{ + struct cgi_request *r = cgi_req_get_by_fd(socket); + + if (r) { + + /* This kind of sucks, but epoll can give a hangup while + we still have a lot of data to read */ + while (1) { + const int ret = _mkp_event_read(socket); + if (ret == MK_PLUGIN_RET_EVENT_CLOSE) { + done(socket); + break; + } + _mkp_event_write(r->socket); + } + return MK_PLUGIN_RET_EVENT_OWNED; } -- 1.7.2.1
_______________________________________________ Monkey mailing list [email protected] http://lists.monkey-project.com/listinfo/monkey
