diff options
author | Christian Pointner <equinox@helsinki.at> | 2015-05-14 15:18:10 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2015-05-14 15:18:10 (GMT) |
commit | 59246b0e11664bd6c1a26a12a519192f8a4f9893 (patch) | |
tree | 4f98845c82ed2292c19ac9ab67859164efffa614 | |
parent | 3973788d772b7eb95284222a1ef9a7c9a00dd974 (diff) |
fixed client remove
-rw-r--r-- | src/tcpserver.lua | 15 |
1 files changed, 9 insertions, 6 deletions
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() |