Fix C2S session close on server shutdown

This commit is contained in:
Evgeniy Khramtsov 2014-05-08 21:28:12 +04:00
parent 90a5c054d4
commit 181e7a823e
2 changed files with 17 additions and 4 deletions

View File

@ -177,10 +177,12 @@ add_windows_nameservers() ->
broadcast_c2s_shutdown() ->
Children = supervisor:which_children(ejabberd_c2s_sup),
Children = ejabberd_sm:get_all_pids(),
lists:foreach(
fun({_, C2SPid, _, _}) ->
C2SPid ! system_shutdown
fun(C2SPid) when node(C2SPid) == node() ->
C2SPid ! system_shutdown;
(_) ->
ok
end, Children).
%%%

View File

@ -59,6 +59,7 @@
get_user_info/3,
get_user_ip/3,
get_max_user_sessions/2,
get_all_pids/0,
is_existing_resource/3
]).
@ -283,13 +284,23 @@ dirty_get_my_sessions_list() ->
[{'==', {node, '$1'}, node()}],
['$_']}]).
-spec get_vh_session_list(binary()) -> [ljid()].
get_vh_session_list(Server) ->
LServer = jlib:nameprep(Server),
mnesia:dirty_select(session,
[{#session{usr = '$1', _ = '_'},
[{'==', {element, 2, '$1'}, LServer}], ['$1']}]).
-spec get_vh_session_list(binary()) -> [ljid()].
-spec get_all_pids() -> [pid()].
get_all_pids() ->
mnesia:dirty_select(
session,
ets:fun2ms(
fun(#session{sid = {_, Pid}}) ->
Pid
end)).
get_vh_session_number(Server) ->
LServer = jlib:nameprep(Server),