You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2019/01/16 17:41:21 UTC

[mynewt-core] branch master updated: sys/fault: Only crash when in error state

This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new b1945b4  sys/fault: Only crash when in error state
b1945b4 is described below

commit b1945b4e1b2bb3086b4f2643889bde1b1c96dca3
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Fri Jan 11 15:50:22 2019 -0800

    sys/fault: Only crash when in error state
    
    This change only affects debug builds (when `DEBUG_PANIC_ENABLED` is
    set).
    
    Prior to this change, (when debug mode is used) a crash was triggered
    whenever the a fault recorder changed state.  There are three fault
    states:
        * GOOD
        * WARN
        * ERROR
    
    Typically, an application is configured to log a message when a
    recorder enters the WARN state, and to reboot the system upon entering
    the ERROR state.  However, in debug mode, the device would crash as soon
    as the WARN state was entered.
    
    After commit: debug builds only crash when the ERROR state is entered.
    The WARN state behaves the same in debug and non-debug builds.
---
 sys/fault/src/fault.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/sys/fault/src/fault.c b/sys/fault/src/fault.c
index 928458b..0144ff9 100644
--- a/sys/fault/src/fault.c
+++ b/sys/fault/src/fault.c
@@ -168,10 +168,11 @@ fault_process(struct fault_recorder *recorder, bool is_failure)
         /* The domain seems to be working; decrease chronic failure count. */
         fault_decrease_chronic_count(recorder->domain_id);
     } else {
-        /* Fault detected; trigger a crash in debug builds. */
-        DEBUG_PANIC();
-
         if (state == FAULT_STATE_ERROR) {
+            /* Fault detected; trigger a crash in debug builds. */
+            DEBUG_PANIC();
+
+            /* Increase chronic fail count and persist. */
             fault_increase_chronic_count(recorder->domain_id);
         }
     }