mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-24 17:29:28 +01:00
Resend queue to self before calling terminate
This commit is contained in:
parent
d65b785f5d
commit
8aaf9bffa0
@ -395,7 +395,8 @@ loop(Parent, Name, StateName, StateData, Mod, Time, Debug,
|
|||||||
{process_limit, Limit} ->
|
{process_limit, Limit} ->
|
||||||
Reason = {process_limit, Limit},
|
Reason = {process_limit, Limit},
|
||||||
Msg = {'EXIT', Parent, {error, {process_limit, Limit}}},
|
Msg = {'EXIT', Parent, {error, {process_limit, Limit}}},
|
||||||
terminate(Reason, Name, Msg, Mod, StateName, StateData, Debug)
|
terminate(Reason, Name, Msg, Mod, StateName, StateData, Debug,
|
||||||
|
queue:new())
|
||||||
end,
|
end,
|
||||||
process_message(Parent, Name, StateName, StateData,
|
process_message(Parent, Name, StateName, StateData,
|
||||||
Mod, Time, Debug, Limits, Queue, QueueLen).
|
Mod, Time, Debug, Limits, Queue, QueueLen).
|
||||||
@ -451,7 +452,8 @@ decode_msg(Msg,Parent, Name, StateName, StateData, Mod, Time, Debug,
|
|||||||
[Name, StateName, StateData,
|
[Name, StateName, StateData,
|
||||||
Mod, Time, Limits, Queue, QueueLen], Hib);
|
Mod, Time, Limits, Queue, QueueLen], Hib);
|
||||||
{'EXIT', Parent, Reason} ->
|
{'EXIT', Parent, Reason} ->
|
||||||
terminate(Reason, Name, Msg, Mod, StateName, StateData, Debug);
|
terminate(Reason, Name, Msg, Mod, StateName, StateData, Debug,
|
||||||
|
Queue);
|
||||||
_Msg when Debug == [] ->
|
_Msg when Debug == [] ->
|
||||||
handle_msg(Msg, Parent, Name, StateName, StateData,
|
handle_msg(Msg, Parent, Name, StateName, StateData,
|
||||||
Mod, Time, Limits, Queue, QueueLen);
|
Mod, Time, Limits, Queue, QueueLen);
|
||||||
@ -471,8 +473,9 @@ system_continue(Parent, Debug, [Name, StateName, StateData,
|
|||||||
Limits, Queue, QueueLen).
|
Limits, Queue, QueueLen).
|
||||||
|
|
||||||
system_terminate(Reason, _Parent, Debug,
|
system_terminate(Reason, _Parent, Debug,
|
||||||
[Name, StateName, StateData, Mod, _Time, _Limits]) ->
|
[Name, StateName, StateData, Mod, _Time,
|
||||||
terminate(Reason, Name, [], Mod, StateName, StateData, Debug).
|
_Limits, Queue, _QueueLen]) ->
|
||||||
|
terminate(Reason, Name, [], Mod, StateName, StateData, Debug, Queue).
|
||||||
|
|
||||||
system_code_change([Name, StateName, StateData, Mod, Time,
|
system_code_change([Name, StateName, StateData, Mod, Time,
|
||||||
Limits, Queue, QueueLen],
|
Limits, Queue, QueueLen],
|
||||||
@ -574,19 +577,25 @@ handle_msg(Msg, Parent, Name, StateName, StateData, Mod, _Time,
|
|||||||
_ ->
|
_ ->
|
||||||
normal
|
normal
|
||||||
end,
|
end,
|
||||||
terminate(Reason, Name, Msg, Mod, StateName, NStateData, []);
|
Queue1 =
|
||||||
|
case Reason of
|
||||||
|
normal -> Queue;
|
||||||
|
_ -> queue:new()
|
||||||
|
end,
|
||||||
|
terminate(Reason, Name, Msg, Mod, StateName, NStateData, [],
|
||||||
|
Queue1);
|
||||||
{stop, Reason, NStateData} ->
|
{stop, Reason, NStateData} ->
|
||||||
terminate(Reason, Name, Msg, Mod, StateName, NStateData, []);
|
terminate(Reason, Name, Msg, Mod, StateName, NStateData, [], Queue);
|
||||||
{stop, Reason, Reply, NStateData} when From =/= undefined ->
|
{stop, Reason, Reply, NStateData} when From =/= undefined ->
|
||||||
{'EXIT', R} = (catch terminate(Reason, Name, Msg, Mod,
|
{'EXIT', R} = (catch terminate(Reason, Name, Msg, Mod,
|
||||||
StateName, NStateData, [])),
|
StateName, NStateData, [], Queue)),
|
||||||
reply(From, Reply),
|
reply(From, Reply),
|
||||||
exit(R);
|
exit(R);
|
||||||
{'EXIT', What} ->
|
{'EXIT', What} ->
|
||||||
terminate(What, Name, Msg, Mod, StateName, StateData, []);
|
terminate(What, Name, Msg, Mod, StateName, StateData, [], Queue);
|
||||||
Reply ->
|
Reply ->
|
||||||
terminate({bad_return_value, Reply},
|
terminate({bad_return_value, Reply},
|
||||||
Name, Msg, Mod, StateName, StateData, [])
|
Name, Msg, Mod, StateName, StateData, [], Queue)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
handle_msg(Msg, Parent, Name, StateName, StateData,
|
handle_msg(Msg, Parent, Name, StateName, StateData,
|
||||||
@ -631,19 +640,27 @@ handle_msg(Msg, Parent, Name, StateName, StateData,
|
|||||||
_ ->
|
_ ->
|
||||||
normal
|
normal
|
||||||
end,
|
end,
|
||||||
terminate(Reason, Name, Msg, Mod, StateName, NStateData, Debug);
|
Queue1 =
|
||||||
|
case Reason of
|
||||||
|
normal -> Queue;
|
||||||
|
_ -> queue:new()
|
||||||
|
end,
|
||||||
|
terminate(Reason, Name, Msg, Mod, StateName, NStateData, Debug,
|
||||||
|
Queue1);
|
||||||
{stop, Reason, NStateData} ->
|
{stop, Reason, NStateData} ->
|
||||||
terminate(Reason, Name, Msg, Mod, StateName, NStateData, Debug);
|
terminate(Reason, Name, Msg, Mod, StateName, NStateData, Debug,
|
||||||
|
Queue);
|
||||||
{stop, Reason, Reply, NStateData} when From =/= undefined ->
|
{stop, Reason, Reply, NStateData} when From =/= undefined ->
|
||||||
{'EXIT', R} = (catch terminate(Reason, Name, Msg, Mod,
|
{'EXIT', R} = (catch terminate(Reason, Name, Msg, Mod,
|
||||||
StateName, NStateData, Debug)),
|
StateName, NStateData, Debug,
|
||||||
|
Queue)),
|
||||||
reply(Name, From, Reply, Debug, StateName),
|
reply(Name, From, Reply, Debug, StateName),
|
||||||
exit(R);
|
exit(R);
|
||||||
{'EXIT', What} ->
|
{'EXIT', What} ->
|
||||||
terminate(What, Name, Msg, Mod, StateName, StateData, Debug);
|
terminate(What, Name, Msg, Mod, StateName, StateData, Debug, Queue);
|
||||||
Reply ->
|
Reply ->
|
||||||
terminate({bad_return_value, Reply},
|
terminate({bad_return_value, Reply},
|
||||||
Name, Msg, Mod, StateName, StateData, Debug)
|
Name, Msg, Mod, StateName, StateData, Debug, Queue)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
dispatch({'$gen_event', Event}, Mod, StateName, StateData) ->
|
dispatch({'$gen_event', Event}, Mod, StateName, StateData) ->
|
||||||
@ -679,7 +696,10 @@ reply(Name, {To, Tag}, Reply, Debug, StateName) ->
|
|||||||
%%% Terminate the server.
|
%%% Terminate the server.
|
||||||
%%% ---------------------------------------------------
|
%%% ---------------------------------------------------
|
||||||
|
|
||||||
terminate(Reason, Name, Msg, Mod, StateName, StateData, Debug) ->
|
terminate(Reason, Name, Msg, Mod, StateName, StateData, Debug, Queue) ->
|
||||||
|
lists:foreach(
|
||||||
|
fun(Message) -> self() ! Message end,
|
||||||
|
queue:to_list(Queue)),
|
||||||
case catch Mod:terminate(Reason, StateName, StateData) of
|
case catch Mod:terminate(Reason, StateName, StateData) of
|
||||||
{'EXIT', R} ->
|
{'EXIT', R} ->
|
||||||
error_info(Mod, R, Name, Msg, StateName, StateData, Debug),
|
error_info(Mod, R, Name, Msg, StateName, StateData, Debug),
|
||||||
@ -762,7 +782,8 @@ get_msg(Msg) -> Msg.
|
|||||||
%% Status information
|
%% Status information
|
||||||
%%-----------------------------------------------------------------
|
%%-----------------------------------------------------------------
|
||||||
format_status(Opt, StatusData) ->
|
format_status(Opt, StatusData) ->
|
||||||
[PDict, SysState, Parent, Debug, [Name, StateName, StateData, Mod, _Time]] =
|
[PDict, SysState, Parent, Debug,
|
||||||
|
[Name, StateName, StateData, Mod, _Time, _Limits, _Queue, _QueueLen]] =
|
||||||
StatusData,
|
StatusData,
|
||||||
NameTag = if is_pid(Name) ->
|
NameTag = if is_pid(Name) ->
|
||||||
pid_to_list(Name);
|
pid_to_list(Name);
|
||||||
|
Loading…
Reference in New Issue
Block a user