summaryrefslogtreecommitdiff
path: root/src/mode-tcpserver.lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/mode-tcpserver.lua')
-rw-r--r--src/mode-tcpserver.lua14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/mode-tcpserver.lua b/src/mode-tcpserver.lua
index 78e416c..ced0f7d 100644
--- a/src/mode-tcpserver.lua
+++ b/src/mode-tcpserver.lua
@@ -52,18 +52,16 @@ function add_client(hdl)
end
function remove_client(c)
- local idx = 0
- local found = false
- for i, client in ipairs(clients) do
- if client == c then
- found = true
- idx = i
+ local idx = -1
+ for n, client in ipairs(clients) do
+ if client.getfd() == c.getfd() then
+ idx = n
break
end
end
- if found then
- log.printf(log.DEBUG, "removing client(" .. c.hdl:getfd() .. ")")
+ if idx > 0 then
+ log.printf(log.DEBUG, "removing client(" .. c.getfd() .. ")")
c.hdl:close()
table.remove(clients, idx)
end