From e6e31791abf090fe7e0bd3e5970b44830d087c4a Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Thu, 15 Dec 2011 11:57:30 +0100 Subject: Leave control back to gen_server during supervisor's restart loop When an attempt to restart a child failed, supervisor would earlier keep the execution flow and try to restart the child over and over again until it either succeeded or the restart frequency limit was reached. If none of these happened, supervisor would hang forever in this loop. This commit adds a timer of 0 ms where the control is left back to the gen_server which implements the supervisor. This way any incoming request to the supervisor will be handled - which could help breaking the infinite loop - e.g. shutdown request for the supervisor or for the problematic child. This introduces some incompatibilities in stdlib due to new return values from supervisor: * restart_child/2 can now return {error,restarting} * delete_child/2 can now return {error,restarting} * which_children/1 returns a list of {Id,Child,Type,Mods}, where Child, in addition to the old pid() or 'undefined', now also can be 'restarting'. --- lib/stdlib/doc/src/supervisor.xml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'lib/stdlib/doc') diff --git a/lib/stdlib/doc/src/supervisor.xml b/lib/stdlib/doc/src/supervisor.xml index d1e62230bc..35f4f82264 100644 --- a/lib/stdlib/doc/src/supervisor.xml +++ b/lib/stdlib/doc/src/supervisor.xml @@ -399,10 +399,11 @@ child_spec() = {Id,StartFunc,Restart,Shutdown,Type,Modules} SupRef.

If successful, the function returns ok. If the child specification identified by Id exists but - the corresponding child process is running, the function - returns {error,running}. If the child specification - identified by Id does not exist, the function returns - {error,not_found}.

+ the corresponding child process is running or about to be restarted, + the function returns {error,running} or + {error,restarting} respectively. If the child specification + identified by Id does not exist, the function + returns {error,not_found}.

@@ -462,7 +463,8 @@ child_spec() = {Id,StartFunc,Restart,Shutdown,Type,Modules}

Child - the pid of the corresponding child - process, or undefined if there is no such process.

+ process, the atom restarting if the process is about to be + restarted or undefined if there is no such process.

Type - as defined in the child specification.

-- cgit v1.2.3