aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src/supervisor.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2015-04-22 13:04:30 +0200
committerBjörn Gustavsson <[email protected]>2015-04-22 14:11:44 +0200
commit47e7f00fe52ceb675c94a4800c297ce98d6bee30 (patch)
tree603f83634f2b1f04c4c249ea536796372c968cb6 /lib/stdlib/src/supervisor.erl
parent5201e1852b034a6566828e1ba267c2afaa017933 (diff)
downloadotp-47e7f00fe52ceb675c94a4800c297ce98d6bee30.tar.gz
otp-47e7f00fe52ceb675c94a4800c297ce98d6bee30.tar.bz2
otp-47e7f00fe52ceb675c94a4800c297ce98d6bee30.zip
supervisor: Correct restart handling
fbaa0bec replaced the use of now/0 with erlang:monotonic_time/1 but at the same time introduced a bug in inPeriod/3 so that it would always return 'true' (the subtraction Time - Now would always result in a non-positive number that would always be less than Period). The symptoms of the bug is that when a child has been restarted the maximum number of times allowed, the supervisor will terminate, regardless of how much time that elapses between the restarts. There was no test case that detected this problem. Add the missing test case to ensure that this bug stays killed. Reported-by: Rafał Studnicki
Diffstat (limited to 'lib/stdlib/src/supervisor.erl')
-rw-r--r--lib/stdlib/src/supervisor.erl9
1 files changed, 2 insertions, 7 deletions
diff --git a/lib/stdlib/src/supervisor.erl b/lib/stdlib/src/supervisor.erl
index 7c0cd8b26a..67655b1145 100644
--- a/lib/stdlib/src/supervisor.erl
+++ b/lib/stdlib/src/supervisor.erl
@@ -1403,13 +1403,8 @@ add_restart([R|Restarts], Now, Period) ->
add_restart([], _, _) ->
[].
-inPeriod(Time, Now, Period) ->
- case Time - Now of
- T when T > Period ->
- false;
- _ ->
- true
- end.
+inPeriod(Then, Now, Period) ->
+ Now =< Then + Period.
%%% ------------------------------------------------------
%%% Error and progress reporting.