Skip to content

Commit a208ea2

Browse files
committed
replace brutal die in doRestartChild with stopWith
See discussion on 6656a92.
1 parent 6656a92 commit a208ea2

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/Control/Distributed/Process/Platform/Supervisor.hs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,14 +1149,14 @@ tryRestartChild pid st active' spec reason
11491149
| True <- isTemporary (childRestart spec) = continue childRemoved
11501150
| DiedNormal <- reason
11511151
, True <- isIntrinsic (childRestart spec) = stopWith updateStopped ExitNormal
1152-
| otherwise = continue =<< doRestartChild pid spec reason st
1152+
| otherwise = doRestartChild pid spec reason st
11531153
where
11541154
childDown = (active ^= active') $ updateStopped
11551155
childRemoved = (active ^= active') $ removeChild spec st
11561156
updateStopped = maybe st id $ updateChild chKey (setChildStopped False) st
11571157
chKey = childKey spec
11581158

1159-
doRestartChild :: ProcessId -> ChildSpec -> DiedReason -> State -> Process State
1159+
doRestartChild :: ProcessId -> ChildSpec -> DiedReason -> State -> Process (ProcessAction State)
11601160
doRestartChild _ spec _ state = do -- TODO: use ProcessId and DiedReason to log
11611161
state' <- addRestart state
11621162
case state' of
@@ -1167,23 +1167,26 @@ doRestartChild _ spec _ state = do -- TODO: use ProcessId and DiedReason to log
11671167
Just st -> do
11681168
start' <- doStartChild spec st
11691169
case start' of
1170-
Right (ref, st') -> do
1171-
return $ markActive st' ref spec
1170+
Right (ref, st') -> continue $ markActive st' ref spec
11721171
Left err -> do
11731172
-- All child failures are handled via monitor signals, apart from
11741173
-- BadClosure and UnresolvableAddress from the StarterProcess
11751174
-- variants of ChildStart, which both come back from
11761175
-- doStartChild as (Left err).
11771176
sup <- getSelfPid
1178-
logEntry Log.error $
1179-
mkReport "Unrecoverable error in child" sup (childKey spec) (show err)
11801177
if isTemporary (childRestart spec)
1181-
then return $ ( (active ^: Map.filter (/= chKey))
1178+
then do
1179+
logEntry Log.warning $
1180+
mkReport "Error in temporary child" sup (childKey spec) (show err)
1181+
continue $ ( (active ^: Map.filter (/= chKey))
11821182
. (bumpStats Active chType decrement)
11831183
. (bumpStats Specified chType decrement)
1184-
$ removeChild spec st
1185-
)
1186-
else die $ "Unrecoverable error in child " ++ (childKey spec)
1184+
$ removeChild spec st)
1185+
else do
1186+
logEntry Log.error $
1187+
mkReport "Unrecoverable error in child. Stopping supervisor"
1188+
sup (childKey spec) (show err)
1189+
stopWith st $ ExitOther $ "Unrecoverable error in child " ++ (childKey spec)
11871190
-- TODO: convert this to a meaningful exception type
11881191

11891192
where

0 commit comments

Comments
 (0)