aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaweł Chmielowski <pchmielowski@process-one.net>2019-01-22 14:22:15 +0100
committerPaweł Chmielowski <pchmielowski@process-one.net>2019-01-22 14:22:23 +0100
commit74731a5816446326e069e85f374d7a5748332691 (patch)
tree267783c955c910342398411d08a06483e78b14f2 /src
parentFix crash when running reload_config and sql_pool_size option is used (diff)
Make sure that room_destroyed is called even when some code throws in terminate
We observed that some code was throwing exception in muc_room:terminate() and that make this room not properly unregister itself from muc_online table.
Diffstat (limited to 'src')
-rw-r--r--src/mod_muc_room.erl63
1 files changed, 33 insertions, 30 deletions
diff --git a/src/mod_muc_room.erl b/src/mod_muc_room.erl
index 282220431..8bbdd8d97 100644
--- a/src/mod_muc_room.erl
+++ b/src/mod_muc_room.erl
@@ -699,36 +699,39 @@ handle_info(_Info, StateName, StateData) ->
{next_state, StateName, StateData}.
terminate(Reason, _StateName, StateData) ->
- ?INFO_MSG("Stopping MUC room ~s@~s",
- [StateData#state.room, StateData#state.host]),
- ReasonT = case Reason of
- shutdown ->
- <<"You are being removed from the room "
- "because of a system shutdown">>;
- _ -> <<"Room terminates">>
- end,
- Packet = #presence{
- type = unavailable,
- sub_els = [#muc_user{items = [#muc_item{affiliation = none,
- reason = ReasonT,
- role = none}],
- status_codes = [332,110]}]},
- maps:fold(
- fun(LJID, Info, _) ->
- Nick = Info#user.nick,
- case Reason of
- shutdown ->
- send_wrapped(jid:replace_resource(StateData#state.jid, Nick),
- Info#user.jid, Packet,
- ?NS_MUCSUB_NODES_PARTICIPANTS,
- StateData);
- _ -> ok
- end,
- tab_remove_online_user(LJID, StateData)
- end, [], get_users_and_subscribers(StateData)),
- add_to_log(room_existence, stopped, StateData),
- mod_muc:room_destroyed(StateData#state.host, StateData#state.room, self(),
- StateData#state.server_host),
+ try
+ ?INFO_MSG("Stopping MUC room ~s@~s",
+ [StateData#state.room, StateData#state.host]),
+ ReasonT = case Reason of
+ shutdown ->
+ <<"You are being removed from the room "
+ "because of a system shutdown">>;
+ _ -> <<"Room terminates">>
+ end,
+ Packet = #presence{
+ type = unavailable,
+ sub_els = [#muc_user{items = [#muc_item{affiliation = none,
+ reason = ReasonT,
+ role = none}],
+ status_codes = [332,110]}]},
+ maps:fold(
+ fun(LJID, Info, _) ->
+ Nick = Info#user.nick,
+ case Reason of
+ shutdown ->
+ send_wrapped(jid:replace_resource(StateData#state.jid, Nick),
+ Info#user.jid, Packet,
+ ?NS_MUCSUB_NODES_PARTICIPANTS,
+ StateData);
+ _ -> ok
+ end,
+ tab_remove_online_user(LJID, StateData)
+ end, [], get_users_and_subscribers(StateData)),
+ add_to_log(room_existence, stopped, StateData),
+ after
+ mod_muc:room_destroyed(StateData#state.host, StateData#state.room, self(),
+ StateData#state.server_host)
+ end,
ok.
%%%----------------------------------------------------------------------