Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
1495-Fix-storing-children-returning-ignore-on-r...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 1495-Fix-storing-children-returning-ignore-on-restart-in-.patch of Package erlang
From 70a2315b7d7b0487f474ded6577d5e384a823a42 Mon Sep 17 00:00:00 2001 From: Maria Scott <maria-12648430@hnc-agency.org> Date: Fri, 8 Mar 2024 10:34:48 +0100 Subject: [PATCH 1/2] Fix storing children returning ignore on restart in simple_one_for_one --- lib/stdlib/src/supervisor.erl | 9 ++++++++ lib/stdlib/test/supervisor_SUITE.erl | 34 ++++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/lib/stdlib/src/supervisor.erl b/lib/stdlib/src/supervisor.erl index 3c1917db27..b87b73ff3c 100644 --- a/lib/stdlib/src/supervisor.erl +++ b/lib/stdlib/src/supervisor.erl @@ -1371,6 +1371,15 @@ restart(simple_one_for_one, Child, State0) -> end, State2 = dyn_erase(OldPid, State1), case do_start_child_i(M, F, A) of + {ok, undefined} -> + %% The child returned ignore when being restarted. + %% In accordance with the behavior of start_child/2 + %% for simple_one_for_one supervisors, it is dropped + %% from the supervisor. + %% Automatic shutdown is not taken into consideration, + %% since it does not make sense to use it in + %% simple_one_for_one supervisors. + {ok, State2}; {ok, Pid} -> NState = dyn_store(Pid, A, State2), {ok, NState}; diff --git a/lib/stdlib/test/supervisor_SUITE.erl b/lib/stdlib/test/supervisor_SUITE.erl index f7f3aa0ba3..84af3c809e 100644 --- a/lib/stdlib/test/supervisor_SUITE.erl +++ b/lib/stdlib/test/supervisor_SUITE.erl @@ -68,7 +68,8 @@ simple_one_for_one_corruption/1, rest_for_one/1, rest_for_one_escalation/1, rest_for_one_other_child_fails_restart/1, - simple_one_for_one_extra/1, simple_one_for_one_shutdown/1]). + simple_one_for_one_extra/1, simple_one_for_one_shutdown/1, + simple_one_for_one_restart_ignore/1]). %% Misc tests -export([child_unlink/1, tree/1, count_children/1, count_children_supervisor/1, @@ -154,7 +155,7 @@ groups() -> {restart_simple_one_for_one, [], [simple_one_for_one, simple_one_for_one_shutdown, simple_one_for_one_extra, simple_one_for_one_escalation, - simple_one_for_one_corruption]}, + simple_one_for_one_corruption, simple_one_for_one_restart_ignore]}, {restart_rest_for_one, [], [rest_for_one, rest_for_one_escalation, rest_for_one_other_child_fails_restart]}]. @@ -1503,6 +1504,35 @@ simple_one_for_one(Config) when is_list(Config) -> check_exit_reason(SupPid,shutdown). +%%------------------------------------------------------------------------- +%% Test simple_one_for_one children restarts and returning ignore. +simple_one_for_one_restart_ignore(Config) when is_list(Config) -> + process_flag(trap_exit, true), + Self = self(), + lists:foreach( + fun(Restart) -> + Child = {child, {supervisor_3, start_child, []}, Restart, 1000, worker, []}, + {ok, SupPid} = start_link({ok, {{simple_one_for_one, 10, 3600}, [Child]}}), + StarterPid1 = spawn_link(fun() -> supervisor:start_child(SupPid, [child1, Self]) end), + ChildPid1 = receive {child1, CPid1} -> CPid1 end, + ChildPid1 ! {{ok, 0}, Self}, + check_exit([StarterPid1]), + [{undefined, ChildPid1, _, _}] = supervisor:which_children(SupPid), + terminate(ChildPid1, kill), + ChildPid2 = receive {child1, CPid2} -> CPid2 end, + ChildPid2 ! {{ok, 0}, Self}, + [{undefined, ChildPid2, _, _}] = supervisor:which_children(SupPid), + terminate(ChildPid2, kill), + ChildPid3 = receive {child1, CPid3} -> CPid3 end, + ChildPid3 ! {ignore, Self}, + [] = supervisor:which_children(SupPid), + terminate(SupPid, shutdown), + ok = check_exit_reason(SupPid, shutdown) + end, + [transient, permanent] + ). + + %%------------------------------------------------------------------------- %% Test simple_one_for_one children shutdown accordingly to the %% supervisor's shutdown strategy. -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor