Skip to content

Commit

Permalink
fixing closing of the socket session for telnet.
Browse files Browse the repository at this point in the history
it used to lead to coredump due to socket being closed meantime.
  • Loading branch information
fikin committed Sep 18, 2023
1 parent 4154be3 commit f37c12a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lua_modules/telnet/lua/telnet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ local function readAndSendOnceFact(tbl)
return function(skt)
local rec = tbl.pipe:read(1400)
if rec and #rec > 0 then
skt:send(rec)
if not pcall(function() skt:send(rec) end) then
pcall(function() skt:close() end)
onDisconnect()
end
end
end
end
Expand Down

0 comments on commit f37c12a

Please sign in to comment.