@@ -529,16 +529,8 @@ restart_child(Pid, Reason, State) ->
529529 {ok , State }
530530 end .
531531
532- do_restart ({RestartType , Delay }, Reason , Child , State ) ->
533- case restart1 (Child , State ) of
534- {ok , NState } ->
535- {ok , NState };
536- {terminate , NState } ->
537- _TRef = erlang :send_after (trunc (Delay * 1000 ), self (),
538- {delayed_restart ,
539- {{RestartType , Delay }, Reason , Child }}),
540- {ok , state_del_child (Child , NState )}
541- end ;
532+ do_restart ({permanent = RestartType , Delay }, Reason , Child , State ) ->
533+ do_restart_delay ({RestartType , Delay }, Reason , Child , State );
542534do_restart (permanent , Reason , Child , State ) ->
543535 report_error (child_terminated , Reason , Child , State # state .name ),
544536 restart (Child , State );
@@ -552,11 +544,24 @@ do_restart(Type, Reason, Child, State) when Type =:= transient orelse
552544 Type =:= intrinsic ->
553545 report_error (child_terminated , Reason , Child , State # state .name ),
554546 restart (Child , State );
547+ do_restart ({transient = RestartType , Delay }, Reason , Child , State ) ->
548+ do_restart_delay ({RestartType , Delay }, Reason , Child , State );
555549do_restart (temporary , Reason , Child , State ) ->
556550 report_error (child_terminated , Reason , Child , State # state .name ),
557551 NState = state_del_child (Child , State ),
558552 {ok , NState }.
559553
554+ do_restart_delay ({RestartType , Delay }, Reason , Child , State ) ->
555+ case restart1 (Child , State ) of
556+ {ok , NState } ->
557+ {ok , NState };
558+ {terminate , NState } ->
559+ _TRef = erlang :send_after (trunc (Delay * 1000 ), self (),
560+ {delayed_restart ,
561+ {{RestartType , Delay }, Reason , Child }}),
562+ {ok , state_del_child (Child , NState )}
563+ end .
564+
560565del_child_and_maybe_shutdown (intrinsic , Child , State ) ->
561566 {shutdown , state_del_child (Child , State )};
562567del_child_and_maybe_shutdown (_ , Child , State ) ->
0 commit comments