From 59246b0e11664bd6c1a26a12a519192f8a4f9893 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Thu, 14 May 2015 17:18:10 +0200 Subject: fixed client remove diff --git a/src/tcpserver.lua b/src/tcpserver.lua index 6deab81..76c80ad 100644 --- a/src/tcpserver.lua +++ b/src/tcpserver.lua @@ -50,16 +50,19 @@ function add_client(hdl) end function remove_client(c) - local idx = 0 - for idx, client in ipairs(clients) do - if client == c then + local idx = -1 + for n, client in ipairs(clients) do + if client.getfd() == c.getfd() then + idx = n break end end - -- print("removing client(" .. c.hdl:getfd() .. ")") - c.hdl:close() - table.remove(clients, idx) + if idx > 0 then +-- print("removing client(" .. c.getfd() .. ")") + c.hdl:close() + table.remove(clients, idx) + end end function cleanup_clients() -- cgit v0.10.2