|
31 | 31 | %% the MaxT and MaxR parameters to permit the child to be |
32 | 32 | %% restarted. This may require waiting for longer than Delay. |
33 | 33 | %% |
| 34 | +%% Sometimes, you may wish for a transient or intrinsic child to |
| 35 | +%% exit abnormally so that it gets restarted, but still log |
| 36 | +%% nothing. gen_server will log any exit reason other than |
| 37 | +%% 'normal', 'shutdown' or {'shutdown', _}. Thus the exit reason of |
| 38 | +%% {'shutdown', 'restart'} is interpreted to mean you wish the |
| 39 | +%% child to be restarted according to the delay parameters, but |
| 40 | +%% gen_server will not log the error. Thus from gen_server's |
| 41 | +%% perspective it's a normal exit, whilst from supervisor's |
| 42 | +%% perspective, it's an abnormal exit. |
| 43 | +%% |
34 | 44 | %% 4) Added an 'intrinsic' restart type. Like the transient type, this |
35 | 45 | %% type means the child should only be restarted if the child exits |
36 | 46 | %% abnormally. Unlike the transient type, if the child exits |
@@ -536,6 +546,9 @@ do_restart(permanent, Reason, Child, State) -> |
536 | 546 | restart(Child, State); |
537 | 547 | do_restart(Type, normal, Child, State) -> |
538 | 548 | del_child_and_maybe_shutdown(Type, Child, State); |
| 549 | +do_restart({RestartType, Delay}, {shutdown, restart} = Reason, Child, State) |
| 550 | + when RestartType =:= transient orelse RestartType =:= intrinsic -> |
| 551 | + do_restart_delay({RestartType, Delay}, Reason, Child, State); |
539 | 552 | do_restart(Type, {shutdown, _}, Child, State) -> |
540 | 553 | del_child_and_maybe_shutdown(Type, Child, State); |
541 | 554 | do_restart(Type, shutdown, Child = #child{child_type = supervisor}, State) -> |
|
0 commit comments