From 365c517a764ecc0a26693937a58dd600eb3d5c7e Mon Sep 17 00:00:00 2001 From: Tavis Rudd Date: Fri, 25 Apr 2014 00:00:09 -0700 Subject: [PATCH] kill supervisor upon unrecoverable errors in child See discussion on PR #87. --- src/Control/Distributed/Process/Platform/Supervisor.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Control/Distributed/Process/Platform/Supervisor.hs b/src/Control/Distributed/Process/Platform/Supervisor.hs index a40a18a..9b2d193 100644 --- a/src/Control/Distributed/Process/Platform/Supervisor.hs +++ b/src/Control/Distributed/Process/Platform/Supervisor.hs @@ -1169,19 +1169,21 @@ doRestartChild _ spec _ state = do -- TODO: use ProcessId and DiedReason to log case start' of Right (ref, st') -> do return $ markActive st' ref spec - Left err -> do -- TODO: handle this by policy + Left err -> do -- All child failures are handled via monitor signals, apart from -- BadClosure and UnresolvableAddress from the StarterProcess -- variants of ChildStart, which both come back from -- doStartChild as (Left err). -- Since we cannot recover from that, there's no point in trying -- to start this child again (as the closure will never resolve), - -- so we remove the child forthwith. We should provide a policy - -- for handling this situation though... + -- so we remove the child forthwith. sup <- getSelfPid logEntry Log.error $ mkReport "Unrecoverable error in child" sup (childKey spec) (show err) - return $ ( (active ^: Map.filter (/= chKey)) + if (isTemporary (childRestart spec)) + -- TODO: convert this to a meaningful exception type + then die $ "Unrecoverable error in child " ++ (childKey spec) + else return $ ( (active ^: Map.filter (/= chKey)) . (bumpStats Active chType decrement) . (bumpStats Specified chType decrement) $ removeChild spec st