Comparison

mod_smacks/mod_smacks.lua @ 1438:feca77ad88ac

mod_smacks: Backout ed2a9c00b5c4, need a better solution
author Kim Alvefur <zash@zash.se>
date Tue, 17 Jun 2014 08:01:52 +0200
parent 1416:7ddb522d9b28
child 1517:8ac4438925cf
comparison
equal deleted inserted replaced
1437:161bbe0b9dd3 1438:feca77ad88ac
17 local sm2_attr = { xmlns = xmlns_sm2 }; 17 local sm2_attr = { xmlns = xmlns_sm2 };
18 local sm3_attr = { xmlns = xmlns_sm3 }; 18 local sm3_attr = { xmlns = xmlns_sm3 };
19 19
20 local resume_timeout = module:get_option_number("smacks_hibernation_time", 300); 20 local resume_timeout = module:get_option_number("smacks_hibernation_time", 300);
21 local s2s_smacks = module:get_option_boolean("smacks_enabled_s2s", false); 21 local s2s_smacks = module:get_option_boolean("smacks_enabled_s2s", false);
22 local max_queue_size = module:get_option_number("smacks_max_queue_size", 500);
23 local max_unacked_stanzas = module:get_option_number("smacks_max_unacked_stanzas", 0); 22 local max_unacked_stanzas = module:get_option_number("smacks_max_unacked_stanzas", 0);
24 local core_process_stanza = prosody.core_process_stanza; 23 local core_process_stanza = prosody.core_process_stanza;
25 local sessionmanager = require"core.sessionmanager"; 24 local sessionmanager = require"core.sessionmanager";
26 25
27 local c2s_sessions = module:shared("/*/c2s/sessions"); 26 local c2s_sessions = module:shared("/*/c2s/sessions");
89 88
90 if cached_stanza and cached_stanza:get_child("delay", xmlns_delay) == nil then 89 if cached_stanza and cached_stanza:get_child("delay", xmlns_delay) == nil then
91 cached_stanza = cached_stanza:tag("delay", { xmlns = xmlns_delay, from = session.host, stamp = datetime.datetime()}); 90 cached_stanza = cached_stanza:tag("delay", { xmlns = xmlns_delay, from = session.host, stamp = datetime.datetime()});
92 end 91 end
93 92
94 if max_queue_size > 0 and #queue > max_queue_size then
95 session.log("warn", "Too many unacked stanzas");
96 session:close{ condition = "policy-violation"; text = "Too many unacked stanzas"; };
97 end
98 queue[#queue+1] = cached_stanza; 93 queue[#queue+1] = cached_stanza;
99 session.log("debug", "#queue = %d", #queue); 94 session.log("debug", "#queue = %d", #queue);
100 end 95 end
101 if session.hibernating then 96 if session.hibernating then
102 session.log("debug", "hibernating, stanza queued") 97 session.log("debug", "hibernating, stanza queued")