Browse Source

Merge pull request #50 from TriAnMan/fix-memory-leak

Fix a memory leak when the connection is dropped by the client side
Marcos 8 years ago
parent
commit
c218c4f5a8
1 changed files with 6 additions and 0 deletions
  1. 6 0
      httpserver.lua

+ 6 - 0
httpserver.lua

@@ -153,6 +153,12 @@ return function (port)
 
          connection:on("receive", onReceive)
          connection:on("sent", onSent)
+         connection:on("disconnection",function(c)
+            if connectionThread then
+               connectionThread = nil
+               collectgarbage()
+            end
+         end) 
 
       end
    )