modified the initialize/deinitialize logic in CA
authorhyuna0213.jo <hyuna0213.jo@samsung.com>
Wed, 20 Jan 2016 08:53:58 +0000 (17:53 +0900)
committerJon A. Cruz <jonc@osg.samsung.com>
Tue, 26 Jan 2016 17:44:30 +0000 (17:44 +0000)
I changed the initialize/deinitialize logic in CA adapter
and removed the unnecessary code.

Change-Id: Ia9d3dd503f25a393a4053c95c508d1166c574b73
Signed-off-by: hyuna0213.jo <hyuna0213.jo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/4833
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com>
resource/csdk/connectivity/api/cacommon.h
resource/csdk/connectivity/src/bt_edr_adapter/caedradapter.c
resource/csdk/connectivity/src/ip_adapter/caipadapter.c
resource/csdk/connectivity/src/tcp_adapter/catcpadapter.c
resource/csdk/connectivity/src/tcp_adapter/catcpserver.c

index 2ea4017..e1dd2b1 100644 (file)
@@ -503,9 +503,6 @@ typedef struct
     struct calayer
     {
         CAHistory_t requestHistory;  /**< filter IP family in requests */
-        CAHistory_t responseHistory; /**< filter IP family in responses */
-        CATransportFlags_t previousRequestFlags;/**< address family filtering */
-        uint16_t previousRequestMessageId;      /**< address family filtering */
     } ca;
 
 #ifdef TCP_ADAPTER
index cf90302..8e16daa 100644 (file)
@@ -209,14 +209,6 @@ CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback,
     handler.terminate = CATerminateEDR;
     registerCallback(handler, CA_ADAPTER_RFCOMM_BTEDR);
 
-    // Initialize Send/Receive data message queues
-    if (CA_STATUS_OK != CAEDRInitializeQueueHandlers())
-    {
-        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "CAAdapterInitializeQueues API failed");
-        CATerminateEDR();
-        return CA_STATUS_FAILED;
-    }
-
     OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
     return CA_STATUS_OK;
 }
@@ -253,6 +245,16 @@ CAResult_t CAStartEDR()
                   ret);
     }
 
+    // Initialize Send/Receive data message queues
+    if (CA_STATUS_OK != (ret = CAEDRInitializeQueueHandlers()))
+    {
+        OIC_LOG_V(ERROR, EDR_ADAPTER_TAG,
+                  "CAAdapterInitializeQueues failed!, error number [%d] ", ret);
+        CATerminateEDR();
+        return CA_STATUS_FAILED;
+    }
+
+    // Start Send/Receive data message queues
     if (CA_STATUS_OK != (ret = CAAdapterStartQueue()))
     {
         OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "CAAdapterStartQueue failed!, error number [%d] ", ret);
index 46820a7..97e1972 100644 (file)
@@ -398,8 +398,6 @@ CAResult_t CAStopIP()
     {
         CAQueueingThreadStop(g_sendQueueHandle);
     }
-
-    CAIPDeinitializeQueueHandles();
 #endif
 
     CAIPStopNetworkMonitor();
index 3480fc0..d15508c 100644 (file)
@@ -311,8 +311,8 @@ CAResult_t CAStopTCP()
         CAQueueingThreadStop(g_sendQueueHandle);
     }
 
-    CATCPDeinitializeQueueHandles();
     CATCPStopServer();
+
     //Re-initializing the Globals to start them again
     CAInitializeTCPGlobals();
 
index 7f3633b..bd5b5c3 100644 (file)
@@ -555,7 +555,6 @@ void CATCPStopServer()
 
     // set terminate flag
     caglobals.tcp.terminate = true;
-    caglobals.tcp.started = false;
 
     if (caglobals.tcp.shutdownFds[1] != -1)
     {
@@ -563,7 +562,11 @@ void CATCPStopServer()
         // receive thread will stop immediately
     }
 
-    ca_cond_wait(g_condObjectList, g_mutexObjectList);
+    if (caglobals.tcp.started)
+    {
+        ca_cond_wait(g_condObjectList, g_mutexObjectList);
+    }
+    caglobals.tcp.started = false;
 
     // mutex unlock
     ca_mutex_unlock(g_mutexObjectList);