From: <abe...@us...> - 2017-04-24 16:34:34
|
Revision: 8274 http://sourceforge.net/p/astlinux/code/8274 Author: abelbeck Date: 2017-04-24 16:34:31 +0000 (Mon, 24 Apr 2017) Log Message: ----------- lighttpd, fix an issue introduced with lighttpd 1.4.40 where PHP backend streams are buffered using /var/tmp/ . This commit adds the runtime configuration option 'server.stream-response-body = 2' which does not use buffer tempfiles. Previously any PHP generated downloads would fail if larger than the avalable space on /var which is about 9 MB by default. Ref: https://redmine.lighttpd.net/projects/lighttpd/repository/revisions/18a7b2be37041987c5bde264d03a7ee7440ae788 Ref: https://redmine.lighttpd.net/projects/lighttpd/repository/revisions/e4bb56222fa7c1e315ea7d05cb4ea2f0de781534 Modified Paths: -------------- branches/1.0/package/lighttpd/lighttpd.conf Added Paths: ----------- branches/1.0/package/lighttpd/lighttpd-0001-upstream-fix-stream-response-body.patch Added: branches/1.0/package/lighttpd/lighttpd-0001-upstream-fix-stream-response-body.patch =================================================================== --- branches/1.0/package/lighttpd/lighttpd-0001-upstream-fix-stream-response-body.patch (rev 0) +++ branches/1.0/package/lighttpd/lighttpd-0001-upstream-fix-stream-response-body.patch 2017-04-24 16:34:31 UTC (rev 8274) @@ -0,0 +1,143 @@ +commit e4bb56222fa7c1e315ea7d05cb4ea2f0de781534 +Author: Glenn Strauss <gst...@gl...> +Date: Fri Mar 10 02:46:56 2017 -0500 + + [mod_cgi,fastcgi,scgi,proxy] fix streaming response (fixes #2796) + + fix streaming response when server.stream-response-body = 2 + and client catches up to stream from backend + + (thx horgh) + + x-ref: + "mod_fastcgi can fail to read entire response from server" + https://redmine.lighttpd.net/issues/2796 + +diff --git a/src/mod_cgi.c b/src/mod_cgi.c +index 2a50fd3..47196c9 100644 +--- a/src/mod_cgi.c ++++ b/src/mod_cgi.c +@@ -409,7 +409,6 @@ static int cgi_demux_response(server *srv, handler_ctx *hctx) { + if (-1 == (n = read(hctx->fd, hctx->response->ptr, hctx->response->size - 1))) { + if (errno == EAGAIN || errno == EINTR) { + /* would block, wait for signal */ +- fdevent_event_add(srv->ev, &(hctx->fde_ndx), hctx->fd, FDEVENT_IN); + return FDEVENT_HANDLED_NOT_FINISHED; + } + /* error */ +@@ -1442,9 +1441,10 @@ SUBREQUEST_FUNC(mod_cgi_handle_subrequest) { + if (chunkqueue_length(con->write_queue) > 65536 - 4096) { + fdevent_event_clr(srv->ev, &(hctx->fde_ndx), hctx->fd, FDEVENT_IN); + } else if (!(fdevent_event_get_interest(srv->ev, hctx->fd) & FDEVENT_IN)) { +- /* optimistic read from backend, which might re-enable FDEVENT_IN */ ++ /* optimistic read from backend */ + handler_t rc = cgi_recv_response(srv, hctx); /*(might invalidate hctx)*/ + if (rc != HANDLER_GO_ON) return rc; /*(unless HANDLER_GO_ON)*/ ++ fdevent_event_add(srv->ev, &(hctx->fde_ndx), hctx->fd, FDEVENT_IN); + } + } + +diff --git a/src/mod_fastcgi.c b/src/mod_fastcgi.c +index cd84338..b52d493 100644 +--- a/src/mod_fastcgi.c ++++ b/src/mod_fastcgi.c +@@ -2378,7 +2378,6 @@ static int fcgi_demux_response(server *srv, handler_ctx *hctx) { + #if !defined(_WIN32) && !defined(__CYGWIN__) + if (ioctl(hctx->fd, FIONREAD, &toread)) { + if (errno == EAGAIN) { +- fdevent_event_add(srv->ev, &(hctx->fde_ndx), hctx->fd, FDEVENT_IN); + return 0; + } + log_error_write(srv, __FILE__, __LINE__, "sd", +@@ -2411,7 +2410,6 @@ static int fcgi_demux_response(server *srv, handler_ctx *hctx) { + + if (-1 == r) { + if (errno == EAGAIN) { +- fdevent_event_add(srv->ev, &(hctx->fde_ndx), hctx->fd, FDEVENT_IN); + return 0; + } + log_error_write(srv, __FILE__, __LINE__, "sds", +@@ -2421,6 +2419,7 @@ static int fcgi_demux_response(server *srv, handler_ctx *hctx) { + } + } + if (0 == r) { ++ if (!(fdevent_event_get_interest(srv->ev, hctx->fd) & FDEVENT_IN)) return 0; + log_error_write(srv, __FILE__, __LINE__, "ssdsb", + "unexpected end-of-file (perhaps the fastcgi process died):", + "pid:", proc->pid, +@@ -3004,9 +3003,10 @@ SUBREQUEST_FUNC(mod_fastcgi_handle_subrequest) { + if (chunkqueue_length(con->write_queue) > 65536 - 4096) { + fdevent_event_clr(srv->ev, &(hctx->fde_ndx), hctx->fd, FDEVENT_IN); + } else if (!(fdevent_event_get_interest(srv->ev, hctx->fd) & FDEVENT_IN)) { +- /* optimistic read from backend, which might re-enable FDEVENT_IN */ ++ /* optimistic read from backend */ + handler_t rc = fcgi_recv_response(srv, hctx); /*(might invalidate hctx)*/ + if (rc != HANDLER_GO_ON) return rc; /*(unless HANDLER_GO_ON)*/ ++ fdevent_event_add(srv->ev, &(hctx->fde_ndx), hctx->fd, FDEVENT_IN); + } + } + +diff --git a/src/mod_proxy.c b/src/mod_proxy.c +index 85279df..241d24e 100644 +--- a/src/mod_proxy.c ++++ b/src/mod_proxy.c +@@ -843,7 +843,6 @@ static int proxy_demux_response(server *srv, handler_ctx *hctx) { + #if !defined(_WIN32) && !defined(__CYGWIN__) + if (ioctl(hctx->fd, FIONREAD, &b)) { + if (errno == EAGAIN) { +- fdevent_event_add(srv->ev, &(hctx->fde_ndx), hctx->fd, FDEVENT_IN); + return 0; + } + log_error_write(srv, __FILE__, __LINE__, "sd", +@@ -882,7 +881,6 @@ static int proxy_demux_response(server *srv, handler_ctx *hctx) { + + if (-1 == (r = read(hctx->fd, hctx->response->ptr + buffer_string_length(hctx->response), buffer_string_space(hctx->response)))) { + if (errno == EAGAIN) { +- fdevent_event_add(srv->ev, &(hctx->fde_ndx), hctx->fd, FDEVENT_IN); + return 0; + } + log_error_write(srv, __FILE__, __LINE__, "sds", +@@ -955,6 +953,7 @@ static int proxy_demux_response(server *srv, handler_ctx *hctx) { + buffer_reset(hctx->response); + } + } else { ++ if (!(fdevent_event_get_interest(srv->ev, hctx->fd) & FDEVENT_IN)) return 0; + /* reading from upstream done */ + fin = 1; + } +@@ -1183,9 +1182,10 @@ SUBREQUEST_FUNC(mod_proxy_handle_subrequest) { + if (chunkqueue_length(con->write_queue) > 65536 - 4096) { + fdevent_event_clr(srv->ev, &(hctx->fde_ndx), hctx->fd, FDEVENT_IN); + } else if (!(fdevent_event_get_interest(srv->ev, hctx->fd) & FDEVENT_IN)) { +- /* optimistic read from backend, which might re-enable FDEVENT_IN */ ++ /* optimistic read from backend */ + handler_t rc = proxy_recv_response(srv, hctx); /*(might invalidate hctx)*/ + if (rc != HANDLER_GO_ON) return rc; /*(unless HANDLER_GO_ON)*/ ++ fdevent_event_add(srv->ev, &(hctx->fde_ndx), hctx->fd, FDEVENT_IN); + } + } + +diff --git a/src/mod_scgi.c b/src/mod_scgi.c +index ef6ab98..5da4f55 100644 +--- a/src/mod_scgi.c ++++ b/src/mod_scgi.c +@@ -1781,7 +1781,6 @@ static int scgi_demux_response(server *srv, handler_ctx *hctx) { + if (-1 == (n = read(hctx->fd, hctx->response->ptr, hctx->response->size - 1))) { + if (errno == EAGAIN || errno == EINTR) { + /* would block, wait for signal */ +- fdevent_event_add(srv->ev, &(hctx->fde_ndx), hctx->fd, FDEVENT_IN); + return 0; + } + /* error */ +@@ -2443,9 +2442,10 @@ SUBREQUEST_FUNC(mod_scgi_handle_subrequest) { + if (chunkqueue_length(con->write_queue) > 65536 - 4096) { + fdevent_event_clr(srv->ev, &(hctx->fde_ndx), hctx->fd, FDEVENT_IN); + } else if (!(fdevent_event_get_interest(srv->ev, hctx->fd) & FDEVENT_IN)) { +- /* optimistic read from backend, which might re-enable FDEVENT_IN */ ++ /* optimistic read from backend */ + handler_t rc = scgi_recv_response(srv, hctx); /*(might invalidate hctx)*/ + if (rc != HANDLER_GO_ON) return rc; /*(unless HANDLER_GO_ON)*/ ++ fdevent_event_add(srv->ev, &(hctx->fde_ndx), hctx->fd, FDEVENT_IN); + } + } + Modified: branches/1.0/package/lighttpd/lighttpd.conf =================================================================== --- branches/1.0/package/lighttpd/lighttpd.conf 2017-04-23 12:58:53 UTC (rev 8273) +++ branches/1.0/package/lighttpd/lighttpd.conf 2017-04-24 16:34:31 UTC (rev 8274) @@ -12,6 +12,7 @@ server.document-root = "@HTTPDIR@" server.errorlog-use-syslog = "enable" +server.stream-response-body = 2 index-file.names = ( "index.php", "index.html", "index.htm", "default.htm" ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |