Merge branch '1.3-rel' (5fdb8a1)
[iotivity.git] / resource / csdk / connectivity / src / camessagehandler.c
index a3eab7d..fd25d85 100644 (file)
@@ -27,7 +27,7 @@
 #include "camessagehandler.h"
 #include "caremotehandler.h"
 #include "caprotocolmessage.h"
-#include "logger.h"
+#include "experimental/logger.h"
 #include "trace.h"
 #ifndef WITH_UPSTREAM_LIBCOAP
 #include "coap/config.h"
@@ -1145,7 +1145,12 @@ CAResult_t CAInitializeMessageHandler(CATransportAdapter_t transportType)
     }
 
     // initialize interface adapters by controller
-    CAInitializeAdapters(g_threadPoolHandle, transportType);
+    res = CAInitializeAdapters(g_threadPoolHandle, transportType);
+    if (CA_STATUS_OK != res)
+    {
+        OIC_LOG(ERROR, TAG, "Failed to Initialize Adapters.");
+        return res;
+    }
 #else
     // retransmission initialize
     CAResult_t res = CARetransmissionInitialize(&g_retransmissionContext, NULL, CASendUnicastData,
@@ -1165,22 +1170,8 @@ CAResult_t CAInitializeMessageHandler(CATransportAdapter_t transportType)
 void CATerminateMessageHandler()
 {
 #ifndef SINGLE_THREAD
-    CATransportAdapter_t connType = CA_DEFAULT_ADAPTER;
-    u_arraylist_t *list = CAGetSelectedNetworkList();
-    size_t length = u_arraylist_length(list);
-
-    for (size_t i = 0; i < length; i++)
-    {
-        void* ptrType = u_arraylist_get(list, i);
-
-        if (NULL == ptrType)
-        {
-            continue;
-        }
-
-        connType = *(CATransportAdapter_t *)ptrType;
-        CAStopAdapter(connType);
-    }
+    // stop adapters
+    CAStopAdapters();
 
     // stop retransmission
     if (NULL != g_retransmissionContext.threadMutex)