Skip to content

Commit

Permalink
Fix session table cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyshch committed Nov 30, 2017
1 parent cf67b9e commit 8639da0
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/ejabberd_sm_mnesia.erl
Expand Up @@ -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}.
Expand Down

0 comments on commit 8639da0

Please sign in to comment.