Actions
Bug #2894
closedMemory leak if two fcgi calls with one request (authentication and response)
ASK QUESTIONS IN Forums:
Description
Hello,
if lighttpd (1.4.49) is configured to authenticate via fcgi and also responds via a second fcgi (or the same fcgi), the memory grows slowly.
This is because in gw_backend.c the chunk queue is only reset after authentication and then newly initialized in mod_fastcgi.c. The reseted memory remains.
gw_backend.c (line 1117):
static void handler_ctx_clear(gw_handler_ctx *hctx) { /* caller MUST have called gw_backend_close(srv, hctx) if necessary */ ... if (hctx->rb) chunkqueue_reset(hctx->rb); ... }
mod_fastcgi.c (line 511)
static handler_t fcgi_check_extension(server *srv, connection *con, void *p_d, int uri_path_handler) { if (con->mode == p->id) { ... hctx->rb = chunkqueue_init(); } return HANDLER_GO_ON; }
A possible patch that worked for me is to look if the chunk queue already exists:
--- a/src/mod_fastcgi.c 2018-06-22 07:31:34.273162458 +0200 +++ b/src/mod_fastcgi.c 2018-06-22 08:10:17.881130326 +0200 @@ -508,7 +508,10 @@ static handler_t fcgi_check_extension(se hctx->opts.pdata = hctx; hctx->stdin_append = fcgi_stdin_append; hctx->create_env = fcgi_create_env; - hctx->rb = chunkqueue_init(); + if(!hctx->rb) + { + hctx->rb = chunkqueue_init(); + } } return HANDLER_GO_ON;
Updated by gstrauss over 6 years ago
- Status changed from New to Patch Pending
- Target version set to 1.4.50
Thanks for the report. While the FastCGI auth request likely fits in kernel socket send buffer to backend, it would be a good idea to reset hctx->rb if it was used for auth.
--- a/src/mod_fastcgi.c +++ b/src/mod_fastcgi.c @@ -515,7 +515,12 @@ static handler_t fcgi_check_extension(server *srv, connection *con, void *p_d, i hctx->opts.pdata = hctx; hctx->stdin_append = fcgi_stdin_append; hctx->create_env = fcgi_create_env; - hctx->rb = chunkqueue_init(); + if (!hctx->rb) { + hctx->rb = chunkqueue_init(); + } + else { + chunkqueue_reset(hctx->rb); + } } return HANDLER_GO_ON;
Updated by gstrauss about 6 years ago
- Status changed from Patch Pending to Fixed
- % Done changed from 0 to 100
Applied in changeset eb429c9c1981aaf8ab2014fe4dd230d27b2e8309.
Actions
Also available in: Atom