mynewt-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] mkiiskila closed pull request #666: allow OIC resource registration at sysinit() time
Date Thu, 01 Jan 1970 00:00:00 GMT
mkiiskila closed pull request #666: allow OIC resource registration at sysinit() time
URL: https://github.com/apache/mynewt-core/pull/666
 
 
   

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/net/oic/pkg.yml b/net/oic/pkg.yml
index 8bcc4ae06..52c3673ac 100644
--- a/net/oic/pkg.yml
+++ b/net/oic/pkg.yml
@@ -53,4 +53,4 @@ pkg.cflags:
     - "-I@apache-mynewt-core/net/oic/include/oic"
 
 pkg.init:
-    oc_init: 500
+    oc_init: 300
diff --git a/net/oic/src/api/oc_priv.h b/net/oic/src/api/oc_priv.h
index a521303b8..49e65ecd8 100644
--- a/net/oic/src/api/oc_priv.h
+++ b/net/oic/src/api/oc_priv.h
@@ -21,5 +21,6 @@
 
 void oc_rep_init(void);
 void oc_buffer_init(void);
+void oc_ri_mem_init(void);
 
 #endif /* __OC_OC_PRIV_H__ */
diff --git a/net/oic/src/api/oc_rep.c b/net/oic/src/api/oc_rep.c
index 64a1d0639..e0cbd653c 100644
--- a/net/oic/src/api/oc_rep.c
+++ b/net/oic/src/api/oc_rep.c
@@ -326,6 +326,6 @@ void
 oc_rep_init(void)
 {
     os_mempool_init(&oc_rep_objects, EST_NUM_REP_OBJECTS,
-      sizeof(oc_rep_t), oc_rep_objects_area, "oc_rep_o");
+                    sizeof(oc_rep_t), oc_rep_objects_area, "oc_rep_o");
 }
 #endif
diff --git a/net/oic/src/api/oc_ri.c b/net/oic/src/api/oc_ri.c
index 6f85ae553..d65a5b4ab 100644
--- a/net/oic/src/api/oc_ri.c
+++ b/net/oic/src/api/oc_ri.c
@@ -47,7 +47,8 @@
 #endif /* OC_SECURITY */
 
 #ifdef OC_SERVER
-static SLIST_HEAD(, oc_resource) oc_app_resources;
+static SLIST_HEAD(, oc_resource) oc_app_resources =
+    SLIST_HEAD_INITIALIZER(&oc_app_resources);
 static struct os_mempool oc_resource_pool;
 static uint8_t oc_resource_area[OS_MEMPOOL_BYTES(MAX_APP_RESOURCES,
       sizeof(oc_resource_t))];
@@ -209,26 +210,31 @@ oc_ri_get_app_resource_by_uri(const char *uri)
 #endif
 
 void
-oc_ri_init(void)
+oc_ri_mem_init(void)
 {
-  oc_random_init(0); // Fix: allow user to seed RNG.
-
 #ifdef OC_SERVER
-  SLIST_INIT(&oc_app_resources);
   os_mempool_init(&oc_resource_pool, MAX_APP_RESOURCES, sizeof(oc_resource_t),
-    oc_resource_area, "oc_res");
+                  oc_resource_area, "oc_res");
 #endif
+#ifdef OC_CLIENT
+    os_mempool_init(&oc_client_cb_pool, MAX_NUM_CONCURRENT_REQUESTS,
+      sizeof(oc_client_cb_t), oc_client_cb_area, "oc_cl_cbs");
+    oc_rep_init();
+#endif
+    oc_buffer_init();
+}
+
+void
+oc_ri_init(void)
+{
+    oc_random_init(0); // Fix: allow user to seed RNG.
 
 #ifdef OC_CLIENT
-  SLIST_INIT(&oc_client_cbs);
-  os_mempool_init(&oc_client_cb_pool, MAX_NUM_CONCURRENT_REQUESTS,
-    sizeof(oc_client_cb_t), oc_client_cb_area, "oc_cl_cbs");
-  oc_rep_init();
+    SLIST_INIT(&oc_client_cbs);
 #endif
-  oc_buffer_init();
 
-  start_processes();
-  oc_create_discovery_resource();
+    start_processes();
+    oc_create_discovery_resource();
 }
 
 void
diff --git a/net/oic/src/port/mynewt/adaptor.c b/net/oic/src/port/mynewt/adaptor.c
index 3f71d6306..87f52f9f6 100644
--- a/net/oic/src/port/mynewt/adaptor.c
+++ b/net/oic/src/port/mynewt/adaptor.c
@@ -25,6 +25,7 @@
 #include <log/log.h>
 #include "oic/oc_log.h"
 #include "oic/oc_ri.h"
+#include "api/oc_priv.h"
 #include "port/oc_connectivity.h"
 #include "adaptor.h"
 
@@ -219,5 +220,6 @@ void
 oc_init(void)
 {
     SYSINIT_ASSERT_ACTIVE();
+    oc_ri_mem_init();
     oc_evq_set(os_eventq_dflt_get());
 }


 

----------------------------------------------------------------
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

Mime
View raw message