summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/tcpserver.lua15
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()