mirror of
https://github.com/processone/ejabberd.git
synced 2024-10-19 15:32:08 +02:00
When ejabberd stops, send stream close to clients (thanks to Alexey Shchepin)(EJAB-1112)
SVN Revision: 2852
This commit is contained in:
parent
15a27c0566
commit
7cbda8badb
@ -77,6 +77,8 @@ start(_, _) ->
|
|||||||
prep_stop(State) ->
|
prep_stop(State) ->
|
||||||
stop_modules(),
|
stop_modules(),
|
||||||
ejabberd_admin:stop(),
|
ejabberd_admin:stop(),
|
||||||
|
broadcast_c2s_shutdown(),
|
||||||
|
timer:sleep(5000),
|
||||||
State.
|
State.
|
||||||
|
|
||||||
%% All the processes were killed when this function is called
|
%% All the processes were killed when this function is called
|
||||||
@ -198,6 +200,13 @@ add_windows_nameservers() ->
|
|||||||
lists:foreach(fun(IPT) -> inet_db:add_ns(IPT) end, IPTs).
|
lists:foreach(fun(IPT) -> inet_db:add_ns(IPT) end, IPTs).
|
||||||
|
|
||||||
|
|
||||||
|
broadcast_c2s_shutdown() ->
|
||||||
|
Children = supervisor:which_children(ejabberd_c2s_sup),
|
||||||
|
lists:foreach(
|
||||||
|
fun({_, C2SPid, _, _}) ->
|
||||||
|
C2SPid ! system_shutdown
|
||||||
|
end, Children).
|
||||||
|
|
||||||
%%%
|
%%%
|
||||||
%%% PID file
|
%%% PID file
|
||||||
%%%
|
%%%
|
||||||
|
@ -1304,6 +1304,21 @@ handle_info({route, From, To, Packet}, StateName, StateData) ->
|
|||||||
handle_info({'DOWN', Monitor, _Type, _Object, _Info}, _StateName, StateData)
|
handle_info({'DOWN', Monitor, _Type, _Object, _Info}, _StateName, StateData)
|
||||||
when Monitor == StateData#state.socket_monitor ->
|
when Monitor == StateData#state.socket_monitor ->
|
||||||
{stop, normal, StateData};
|
{stop, normal, StateData};
|
||||||
|
handle_info(system_shutdown, StateName, StateData) ->
|
||||||
|
case StateName of
|
||||||
|
wait_for_stream ->
|
||||||
|
Header = io_lib:format(?STREAM_HEADER,
|
||||||
|
["none", ?MYNAME, " version='1.0'", ""]),
|
||||||
|
send_text(StateData, Header),
|
||||||
|
send_element(StateData, ?SERR_SYSTEM_SHUTDOWN),
|
||||||
|
send_text(StateData, ?STREAM_TRAILER),
|
||||||
|
ok;
|
||||||
|
_ ->
|
||||||
|
send_element(StateData, ?SERR_SYSTEM_SHUTDOWN),
|
||||||
|
send_text(StateData, ?STREAM_TRAILER),
|
||||||
|
ok
|
||||||
|
end,
|
||||||
|
{stop, normal, StateData};
|
||||||
handle_info(Info, StateName, StateData) ->
|
handle_info(Info, StateName, StateData) ->
|
||||||
?ERROR_MSG("Unexpected info: ~p", [Info]),
|
?ERROR_MSG("Unexpected info: ~p", [Info]),
|
||||||
fsm_next_state(StateName, StateData).
|
fsm_next_state(StateName, StateData).
|
||||||
|
Loading…
Reference in New Issue
Block a user