From 52178d74302b310d5ee986399e7f24d1a02da58d Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 9 Nov 2024 15:42:31 +0100 Subject: net.server_epoll: Make running out of buffer space a fatal error Prevent Bad Things from happening when the buffer gets full. This of course opens up the possibility of intentionally killing connections by sending much stuff, which need to be mitigated with rate limits elsewhere. --- net/server_epoll.lua | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'net') diff --git a/net/server_epoll.lua b/net/server_epoll.lua index 89b36233..24678842 100644 --- a/net/server_epoll.lua +++ b/net/server_epoll.lua @@ -612,6 +612,8 @@ function interface:write(data) -- Try to flush buffer to make room self:onwritable(); if not buffer:write(prev_buffer) then + self:on("disconnect", "no space left in buffer"); + self:destroy(); return false; end end @@ -622,6 +624,8 @@ function interface:write(data) end self:onwritable(); if not buffer:write(data) then + self:on("disconnect", "no space left in buffer"); + self:destroy(); return false; end end @@ -631,6 +635,8 @@ function interface:write(data) end self:onwritable(); if not buffer:write(data) then + self:on("disconnect", "no space left in buffer"); + self:destroy(); return false; end end -- cgit v1.2.3