25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-24 17:29:28 +01:00

Fix session table cleanup

This commit is contained in:
Alexey Shchepin 2017-11-30 13:31:23 +03:00
parent cf67b9ec54
commit 8639da0e00

View File

@ -111,12 +111,18 @@ handle_cast(_Msg, State) ->
{noreply, State}.
handle_info({mnesia_system_event, {mnesia_down, Node}}, State) ->
ets:select_delete(
session,
ets:fun2ms(
fun(#session{sid = {_, Pid}}) ->
node(Pid) == Node
end)),
Sessions =
ets:select(
session,
ets:fun2ms(
fun(#session{sid = {_, Pid}} = S)
when node(Pid) == Node ->
S
end)),
lists:foreach(
fun(S) ->
mnesia:dirty_delete_object(S)
end, Sessions),
{noreply, State};
handle_info(_Info, State) ->
{noreply, State}.