From 9e08be7b28596b1f377df21b7aaf6a7ba65b71d3 Mon Sep 17 00:00:00 2001 From: Jedrzej Potoniec Date: Mon, 4 Jan 2021 20:30:19 +0100 Subject: [PATCH] httpserver: fix memory leak There was a memory leak related to not dropping all references to fifosock's ssend. --- lua_modules/http/httpserver.lua | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lua_modules/http/httpserver.lua b/lua_modules/http/httpserver.lua index a500613e..edab6028 100644 --- a/lua_modules/http/httpserver.lua +++ b/lua_modules/http/httpserver.lua @@ -86,19 +86,22 @@ do local buf = "" local method, url - local cfini = function() - conn:on("receive", nil) - conn:on("disconnection", nil) - csend(function() - conn:on("sent", nil) - conn:close() - end) - end - local ondisconnect = function(connection) + connection:on("receive", nil) + connection:on("disconnection", nil) connection:on("sent", nil) collectgarbage("collect") end + + local cfini = function() + csend(function() + conn:on("sent", nil) + conn:close() + ondisconnect(conn) + end) + end + + -- header parser local cnt_len = 0