Skip to content

Commit

Permalink
mod_stream_management: add hard threshold for queues.
Browse files Browse the repository at this point in the history
  • Loading branch information
maranda committed Jul 8, 2023
1 parent 2d1e094 commit c05ffc4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions plugins/mod_stream_management.lua
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ local function wrap(session, _r, xmlns_sm) -- SM session wrapper
if not cached:get_child("delay", xmlns_d) then
cached = cached:tag("delay", { xmlns = xmlns_d, from = session.host, stamp = dt() });
end
if #_q > max_queued_stanzas * 2 then
destroy(session, "Too many stanzas sent, server queue over limit");
return false, "Too many stanzas sent, server queue over limit";
end
t_insert(_q, cached);
end
if #_q > max_queued_stanzas then
Expand All @@ -125,6 +129,8 @@ local function wrap(session, _r, xmlns_sm) -- SM session wrapper
reply.attr.type = "error";
reply:tag("error", { type = "cancel" }):tag("recipient-unavailable", { xmlns = xmlns_e });
fire_event("route/process", session, reply);
else
reply = nil;
end
end
t_remove(_q, 1);
Expand Down

0 comments on commit c05ffc4

Please sign in to comment.