Comparison

plugins/muc/mod_muc.lua @ 8662:a4e63b037a2a

MUC: Catch and log error in case of storage failure in iterator over rooms
author Kim Alvefur <zash@zash.se>
date Thu, 15 Mar 2018 06:19:57 +0100
parent 8661:7fc0784491ef
child 8707:fd39c44c0113
comparison
equal deleted inserted replaced
8661:7fc0784491ef 8662:a4e63b037a2a
228 local seen = {}; -- Don't iterate over persistent rooms twice 228 local seen = {}; -- Don't iterate over persistent rooms twice
229 for room in rooms:values() do 229 for room in rooms:values() do
230 coroutine.yield(room); 230 coroutine.yield(room);
231 seen[room.jid] = true; 231 seen[room.jid] = true;
232 end 232 end
233 for room_jid in pairs(persistent_rooms_storage:get(nil) or {}) do 233 local all_persistent_rooms, err = persistent_rooms_storage:get(nil);
234 if not all_persistent_rooms then
235 if err then
236 module:log("error", "Error loading list of persistent rooms, only rooms live in memory were iterated over");
237 module:log("debug", "%s", debug.traceback(err));
238 end
239 return nil;
240 end
241 for room_jid in pairs(all_persistent_rooms) do
234 if not seen[room_jid] then 242 if not seen[room_jid] then
235 local room = restore_room(room_jid); 243 local room = restore_room(room_jid);
236 if room then 244 if room then
237 coroutine.yield(room); 245 coroutine.yield(room);
238 else 246 else