changed code to close the socket generated when initializing.
authorhyuna0213.jo <hyuna0213.jo@samsung.com>
Fri, 8 Apr 2016 01:17:29 +0000 (10:17 +0900)
committerJon A. Cruz <jon@joncruz.org>
Mon, 11 Apr 2016 06:02:50 +0000 (06:02 +0000)
changed code to close the socket generated when initializing.

Change-Id: Ib3f45bfb6f49f14b04088cfcff936e68d7ddb88c
Signed-off-by: hyuna0213.jo <hyuna0213.jo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/7707
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jon A. Cruz <jon@joncruz.org>
(cherry picked from commit dacd2c619da1a042806ca601af6576c8c573381c)
Reviewed-on: https://gerrit.iotivity.org/gerrit/7729

resource/csdk/connectivity/inc/caipinterface.h
resource/csdk/connectivity/src/ip_adapter/caipadapter.c
resource/csdk/connectivity/src/ip_adapter/caipserver.c
resource/csdk/connectivity/src/tcp_adapter/catcpserver.c

index ff344f0..2caf5b1 100644 (file)
@@ -94,6 +94,11 @@ CAResult_t CAIPStartServer(const ca_thread_pool_t threadPool);
 #endif
 
 /**
+ * Close IP socket.
+ */
+void CADeInitializeIPGlobals();
+
+/**
  * Stop IP server.
  */
 void CAIPStopServer();
index 9fd3a4f..308ec6d 100644 (file)
@@ -409,6 +409,7 @@ void CATerminateIP()
     CAIPSetPacketReceiveCallback(NULL);
 
 #ifndef SINGLE_THREAD
+    CADeInitializeIPGlobals();
     CAIPDeinitializeQueueHandles();
 #endif
 }
index c0a571e..c49b064 100644 (file)
@@ -119,6 +119,57 @@ static CAResult_t CAReceiveMessage(int fd, CATransportFlags_t flags);
         flags = FLAGS; \
     }
 
+void CADeInitializeIPGlobals()
+{
+    if (caglobals.ip.u6.fd != -1)
+    {
+        close(caglobals.ip.u6.fd);
+        caglobals.ip.u6.fd = -1;
+    }
+
+    if (caglobals.ip.u6s.fd != -1)
+    {
+        close(caglobals.ip.u6s.fd);
+        caglobals.ip.u6s.fd = -1;
+    }
+
+    if (caglobals.ip.u4.fd != -1)
+    {
+        close(caglobals.ip.u4.fd);
+        caglobals.ip.u4.fd = -1;
+    }
+
+    if (caglobals.ip.u4s.fd != -1)
+    {
+        close(caglobals.ip.u4s.fd);
+        caglobals.ip.u4s.fd = -1;
+    }
+
+    if (caglobals.ip.m6.fd != -1)
+    {
+        close(caglobals.ip.m6.fd);
+        caglobals.ip.m6.fd = -1;
+    }
+
+    if (caglobals.ip.m6s.fd != -1)
+    {
+        close(caglobals.ip.m6s.fd);
+        caglobals.ip.m6s.fd = -1;
+    }
+
+    if (caglobals.ip.m4.fd != -1)
+    {
+        close(caglobals.ip.m4.fd);
+        caglobals.ip.m4.fd = -1;
+    }
+
+    if (caglobals.ip.m4s.fd != -1)
+    {
+        close(caglobals.ip.m4s.fd);
+        caglobals.ip.m4s.fd = -1;
+    }
+}
+
 static void CAReceiveHandler(void *data)
 {
     (void)data;
index bb6f9c1..5334502 100644 (file)
@@ -1,4 +1,4 @@
-/* ****************************************************************j
+/* ****************************************************************
  *
  * Copyright 2015 Samsung Electronics All Rights Reserved.
  *