You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/06/17 15:48:14 UTC

[GitHub] ccollins476ad closed pull request #1198: boot/split: Ensure conf loaded before status read

ccollins476ad closed pull request #1198: boot/split: Ensure conf loaded before status read
URL: https://github.com/apache/mynewt-core/pull/1198
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/boot/split/src/split.c b/boot/split/src/split.c
index 5b9a29e45c..894613e777 100644
--- a/boot/split/src/split.c
+++ b/boot/split/src/split.c
@@ -21,6 +21,7 @@
 #include "os/mynewt.h"
 #include "bootutil/bootutil.h"
 #include "bootutil/image.h"
+#include "config/config.h"
 #include "split/split.h"
 #include "split_priv.h"
 
@@ -112,6 +113,11 @@ split_app_go(void **entry, int toboot)
     int run_app;
     int rc;
 
+    /* Make sure the configuration has been loaded.  We need the persisted
+     * `split/status` value to proceed.
+     */
+    conf_ensure_loaded();
+
     if (toboot) {
         split_mode = split_mode_get();
 
diff --git a/sys/config/include/config/config.h b/sys/config/include/config/config.h
index 77720f005d..811265336a 100644
--- a/sys/config/include/config/config.h
+++ b/sys/config/include/config/config.h
@@ -188,6 +188,13 @@ int conf_register(struct conf_handler *cf);
  */
 int conf_load(void);
 
+/**
+ * @brief Loads the configuration if it hasn't been loaded since reboot.
+ *
+ * @return 0 on success, non-zero on failure.
+ */
+int conf_ensure_loaded(void);
+
 /**
  * Save currently running configuration. All configuration which is different
  * from currently persisted values will be saved.
diff --git a/sys/config/src/config.c b/sys/config/src/config.c
index bd125d10d3..9d06e7307d 100644
--- a/sys/config/src/config.c
+++ b/sys/config/src/config.c
@@ -89,7 +89,7 @@ conf_register(struct conf_handler *handler)
 static void
 conf_ev_fn_load(struct os_event *ev)
 {
-    conf_load();
+    conf_ensure_loaded();
 }
 
 /*
diff --git a/sys/config/src/config_store.c b/sys/config/src/config_store.c
index 4dfb13eae8..d3c8e364ab 100644
--- a/sys/config/src/config_store.c
+++ b/sys/config/src/config_store.c
@@ -32,6 +32,7 @@ struct conf_dup_check_arg {
 
 struct conf_store_head conf_load_srcs;
 struct conf_store *conf_save_dst;
+static bool conf_loaded;
 
 void
 conf_src_register(struct conf_store *cs)
@@ -73,6 +74,7 @@ conf_load(void)
      *    commit all
      */
     conf_lock();
+    conf_loaded = true;
     SLIST_FOREACH(cs, &conf_load_srcs, cs_next) {
         cs->cs_itf->csi_load(cs, conf_load_cb, NULL);
         if (SLIST_NEXT(cs, cs_next)) {
@@ -83,6 +85,16 @@ conf_load(void)
     return conf_commit(NULL);
 }
 
+int
+conf_ensure_loaded(void)
+{
+    if (conf_loaded) {
+        return 0;
+    }
+
+    return conf_load();
+}
+
 static void
 conf_dup_check_cb(char *name, char *val, void *cb_arg)
 {
@@ -213,5 +225,6 @@ conf_save(void)
 void
 conf_store_init(void)
 {
+    conf_loaded = false;
     SLIST_INIT(&conf_load_srcs);
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services