Bug fix in set/unset adapter state change callback. (#640) 53/221553/3
authorsenthil.gs@samsung.com <senthil.gs@samsung.com>
Tue, 17 Dec 2019 05:40:07 +0000 (11:10 +0530)
committerPyun DoHyun <dh79.pyun@samsung.com>
Sun, 12 Jan 2020 23:05:43 +0000 (23:05 +0000)
A bug was introduced in a recent patch to reduce code complexity,
This patch fixes the issue.

https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/commit/9a8ff7f20185944857848c6345f87d40ddcd0e87
(cherry-picked from 9a8ff7f20185944857848c6345f87d40ddcd0e87)

Change-Id: I5b15b5ed3bd70e8c81885b7208eba3fbf5ee3330
Signed-off-by: Senthil Kumar G S <senthil.gs@samsung.com>
Signed-off-by: Sudipto <sudipto.bal@samsung.com>
resource/csdk/connectivity/src/ip_adapter/android/caipnwmonitor.c
resource/csdk/connectivity/src/ip_adapter/caipnwmonitor_common.c
resource/csdk/connectivity/src/ip_adapter/caipnwmonitor_common.h
resource/csdk/connectivity/src/ip_adapter/linux/caipnwmonitor.c
resource/csdk/connectivity/src/ip_adapter/tizen/caipnwmonitor.c

index 05cddc7..50d66de 100644 (file)
@@ -136,12 +136,12 @@ static void CAIPPassNetworkChangesToAdapter(CANetworkStatus_t status)
 CAResult_t CAIPSetNetworkMonitorCallback(CAIPAdapterStateChangeCallback callback,
                                          CATransportAdapter_t adapter)
 {
-    return CAIPSetNetworkMonitorCallbackInternal(callback, adapter, g_adapterCallbackList);
+    return CAIPSetNetworkMonitorCallbackInternal(callback, adapter, &g_adapterCallbackList);
 }
 
 CAResult_t CAIPUnSetNetworkMonitorCallback(CATransportAdapter_t adapter)
 {
-    return CAIPUnSetNetworkMonitorCallbackInternal(adapter, g_adapterCallbackList);
+    return CAIPUnSetNetworkMonitorCallbackInternal(adapter, &g_adapterCallbackList);
 }
 
 u_arraylist_t *CAFindInterfaceChange()
index 1fcb957..9203401 100644 (file)
@@ -54,7 +54,7 @@ void CAIPPassNetworkChangesToAdapterInternal(CANetworkStatus_t status,
 }
 
 CAResult_t CAIPSetNetworkMonitorCallbackInternal(CAIPAdapterStateChangeCallback callback,
-                                         CATransportAdapter_t adapter, CAIPCBData_t *adapterCallbackList)
+                                         CATransportAdapter_t adapter, CAIPCBData_t **adapterCallbackList)
 {
     if (!callback)
     {
@@ -63,7 +63,8 @@ CAResult_t CAIPSetNetworkMonitorCallbackInternal(CAIPAdapterStateChangeCallback
     }
 
     CAIPCBData_t *cbitem = NULL;
-    LL_FOREACH(adapterCallbackList, cbitem)
+    CAIPCBData_t *list = *adapterCallbackList;
+    LL_FOREACH(list, cbitem)
     {
         if (cbitem && adapter == cbitem->adapter && callback == cbitem->callback)
         {
@@ -81,22 +82,25 @@ CAResult_t CAIPSetNetworkMonitorCallbackInternal(CAIPAdapterStateChangeCallback
 
     cbitem->adapter = adapter;
     cbitem->callback = callback;
-    LL_APPEND(adapterCallbackList, cbitem);
+    LL_APPEND(list, cbitem);
+    *adapterCallbackList = list;
 
     return CA_STATUS_OK;
 }
 
 CAResult_t CAIPUnSetNetworkMonitorCallbackInternal(CATransportAdapter_t adapter,
-                                         CAIPCBData_t *adapterCallbackList)
+                                         CAIPCBData_t **adapterCallbackList)
 {
     CAIPCBData_t *cbitem = NULL;
     CAIPCBData_t *tmpCbitem = NULL;
-    LL_FOREACH_SAFE(adapterCallbackList, cbitem, tmpCbitem)
+    CAIPCBData_t *list = *adapterCallbackList;
+    LL_FOREACH_SAFE(list, cbitem, tmpCbitem)
     {
         if (cbitem && adapter == cbitem->adapter)
         {
             OIC_LOG(DEBUG, TAG, "remove specific callback");
-            LL_DELETE(adapterCallbackList, cbitem);
+            LL_DELETE(list, cbitem);
+            *adapterCallbackList = list;
             OICFree(cbitem);
             return CA_STATUS_OK;
         }
index 949d0fa..110c623 100644 (file)
@@ -49,10 +49,10 @@ void CAIPPassNetworkChangesToAdapterInternal(CANetworkStatus_t status,
                                          CAIPCBData_t *adapterCallbackList, CAIPAdapterPlatform_t platform);
 
 CAResult_t CAIPSetNetworkMonitorCallbackInternal(CAIPAdapterStateChangeCallback callback,
-                                         CATransportAdapter_t adapter, CAIPCBData_t *adapterCallbackList);
+                                         CATransportAdapter_t adapter, CAIPCBData_t **adapterCallbackList);
 
 CAResult_t CAIPUnSetNetworkMonitorCallbackInternal(CATransportAdapter_t adapter,
-                                         CAIPCBData_t *adapterCallbackList);
+                                         CAIPCBData_t **adapterCallbackList);
 
 #ifdef __cplusplus
 }
index 39fc257..b93ea8d 100644 (file)
@@ -234,12 +234,12 @@ static void CAIPPassNetworkChangesToAdapter(CANetworkStatus_t status)
 CAResult_t CAIPSetNetworkMonitorCallback(CAIPAdapterStateChangeCallback callback,
                                          CATransportAdapter_t adapter)
 {
-    return CAIPSetNetworkMonitorCallbackInternal(callback, adapter, g_adapterCallbackList);
+    return CAIPSetNetworkMonitorCallbackInternal(callback, adapter, &g_adapterCallbackList);
 }
 
 CAResult_t CAIPUnSetNetworkMonitorCallback(CATransportAdapter_t adapter)
 {
-    return CAIPUnSetNetworkMonitorCallbackInternal(adapter, g_adapterCallbackList);
+    return CAIPUnSetNetworkMonitorCallbackInternal(adapter, &g_adapterCallbackList);
 }
 
 static CAInterface_t *CANewInterfaceItem(int index, const char *name, int family,
index 036b0f1..3486343 100644 (file)
@@ -89,12 +89,12 @@ static void CAIPPassNetworkChangesToAdapter(CANetworkStatus_t status)
 CAResult_t CAIPSetNetworkMonitorCallback(CAIPAdapterStateChangeCallback callback,
                                          CATransportAdapter_t adapter)
 {
-    return CAIPSetNetworkMonitorCallbackInternal(callback, adapter, g_adapterCallbackList);
+    return CAIPSetNetworkMonitorCallbackInternal(callback, adapter, &g_adapterCallbackList);
 }
 
 CAResult_t CAIPUnSetNetworkMonitorCallback(CATransportAdapter_t adapter)
 {
-    return CAIPUnSetNetworkMonitorCallbackInternal(adapter, g_adapterCallbackList);
+    return CAIPUnSetNetworkMonitorCallbackInternal(adapter, &g_adapterCallbackList);
 }
 
 u_arraylist_t *CAFindInterfaceChange()