Added check to disallow more than one instance of the RI Layer's C SDK.
authorJoseph Morrow <joseph.l.morrow@intel.com>
Thu, 16 Apr 2015 19:02:42 +0000 (15:02 -0400)
committerErich Keane <erich.keane@intel.com>
Mon, 20 Apr 2015 05:59:01 +0000 (05:59 +0000)
Without proper re-entrancy, the RI Layer's C SDK should not support or try
to support more than one instance of the stack. If it does, unknown
behavior may occur. This commit eliminates this possible cause for error.

Change-Id: Ib85d29cdd2b8fa55a7415f57e8ec7e88bc164927
Signed-off-by: Joseph Morrow <joseph.l.morrow@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/749
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Sachin Agrawal <sachin.agrawal@intel.com>
Reviewed-by: Doug Hudson <douglas.hudson@intel.com>
Reviewed-by: Erich Keane <erich.keane@intel.com>
resource/csdk/stack/src/ocstack.c

index 08cd487..37ffcb8 100644 (file)
@@ -1599,6 +1599,13 @@ bool ParseIPv4Address(char * ipAddrStr, uint8_t * ipAddr, uint16_t * port)
 
 OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
 {
+    if(stackState == OC_STACK_INITIALIZED)
+    {
+        OC_LOG(INFO, TAG, PCF("Subsequent calls to OCInit() without calling \
+                OCStop() between them are ignored."));
+        return OC_STACK_OK;
+    }
+
     (void) ipAddr;
     (void) port;
     OCStackResult result = OC_STACK_ERROR;