aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src/supervisor.erl
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2016-05-25 10:29:18 +0200
committerSiri Hansen <[email protected]>2016-05-25 10:29:18 +0200
commitc126081ca43145412f72a1b5cbae6919c22de28e (patch)
tree08bcc80af6e069b21458e8a02713656bd7c053a9 /lib/stdlib/src/supervisor.erl
parent90bd9b2921f61854771ba2924abd05fa32d46b1f (diff)
parent44d5789619c70863af918ee5e2bdd7d411e68e80 (diff)
downloadotp-c126081ca43145412f72a1b5cbae6919c22de28e.tar.gz
otp-c126081ca43145412f72a1b5cbae6919c22de28e.tar.bz2
otp-c126081ca43145412f72a1b5cbae6919c22de28e.zip
Merge branch 'josevalim/supervisor-try-again-restart/PR-1001/OTP-13618'
* josevalim/supervisor-try-again-restart/PR-1001/OTP-13618: Avoid potential timer bottleneck on supervisor restart
Diffstat (limited to 'lib/stdlib/src/supervisor.erl')
-rw-r--r--lib/stdlib/src/supervisor.erl16
1 files changed, 5 insertions, 11 deletions
diff --git a/lib/stdlib/src/supervisor.erl b/lib/stdlib/src/supervisor.erl
index 38b764541a..a594c66fa7 100644
--- a/lib/stdlib/src/supervisor.erl
+++ b/lib/stdlib/src/supervisor.erl
@@ -246,7 +246,7 @@ check_childspecs(ChildSpecs) when is_list(ChildSpecs) ->
check_childspecs(X) -> {error, {badarg, X}}.
%%%-----------------------------------------------------------------
-%%% Called by timer:apply_after from restart/2
+%%% Called by restart/2
-spec try_again_restart(SupRef, Child) -> ok when
SupRef :: sup_ref(),
Child :: child_id() | pid().
@@ -571,8 +571,8 @@ count_child(#child{pid = Pid, child_type = supervisor},
end.
-%%% If a restart attempt failed, this message is sent via
-%%% timer:apply_after(0,...) in order to give gen_server the chance to
+%%% If a restart attempt failed, this message is cast
+%%% from restart/2 in order to give gen_server the chance to
%%% check it's inbox before trying again.
-spec handle_cast({try_again_restart, child_id() | pid()}, state()) ->
{'noreply', state()} | {stop, shutdown, state()}.
@@ -790,16 +790,10 @@ restart(Child, State) ->
Id = if ?is_simple(State) -> Child#child.pid;
true -> Child#child.name
end,
- {ok, _TRef} = timer:apply_after(0,
- ?MODULE,
- try_again_restart,
- [self(),Id]),
+ ok = try_again_restart(self(), Id),
{ok,NState2};
{try_again, NState2, #child{name=ChName}} ->
- {ok, _TRef} = timer:apply_after(0,
- ?MODULE,
- try_again_restart,
- [self(),ChName]),
+ ok = try_again_restart(self(), ChName),
{ok,NState2};
Other ->
Other