view mod_log_events_by_memory/mod_log_events_by_memory.lua @ 3656:3e0f4d727825

mod_vcard_muc: Add an alternative method of signaling avatar change When the avatar has been changed, a signal is sent that the room configuration has changed. Clients then do a disco#info query to find the SHA-1 of the new avatar. They can then fetch it as before, or not if they have it cached already. This is meant to be less disruptive than signaling via presence, which caused problems for some clients. If clients transition to the new method, the old one can eventually be removed. The namespace is made up while waiting for standardization. Otherwise it is very close to what's described in https://xmpp.org/extensions/inbox/muc-avatars.html
author Kim Alvefur <zash@zash.se>
date Sun, 25 Aug 2019 20:46:43 +0200
parents 5fe34e5f9829
children
line wrap: on
line source

module:set_global();

local treshold = module:get_option_number("log_memory_threshold", 20*1024);

function event_wrapper(handlers, event_name, event_data)
	local memory_before = collectgarbage("count")*1024;
	local ret = handlers(event_name, event_data);
	local memory_after = collectgarbage("count")*1024;
	if (memory_after - memory_before) > treshold then
		module:log("warn", "Memory increased by %g bytes while processing event '%s'", (memory_after - memory_before), event_name);
	end
	return ret;
end

local http_events = require "net.http.server"._events;
module:wrap_object_event(http_events, false, event_wrapper);

module:wrap_event(false, event_wrapper);
function module.add_host(module)
	module:wrap_event(false, event_wrapper);
end