Explorar el Código

httpserver: fix memory leak

There was a memory leak related to not dropping all references to
fifosock's ssend.
Jedrzej Potoniec hace 3 años
padre
commit
9e08be7b28
Se han modificado 1 ficheros con 9 adiciones y 6 borrados
  1. 9 6
      lua_modules/http/httpserver.lua

+ 9 - 6
lua_modules/http/httpserver.lua

@@ -86,19 +86,22 @@ do
       local buf = ""
       local method, url
 
+      local ondisconnect = function(connection)
+        connection:on("receive", nil)
+        connection:on("disconnection", nil)
+        connection:on("sent", nil)
+        collectgarbage("collect")
+      end
+
       local cfini = function()
-        conn:on("receive", nil)
-        conn:on("disconnection", nil)
         csend(function()
           conn:on("sent", nil)
           conn:close()
+          ondisconnect(conn)
         end)
       end
 
-      local ondisconnect = function(connection)
-        connection:on("sent", nil)
-        collectgarbage("collect")
-      end
+
       -- header parser
       local cnt_len = 0