[IOT-1575] Initialize socket fd after closing session
authorhyuna0213.jo <hyuna0213.jo@samsung.com>
Thu, 8 Dec 2016 04:08:21 +0000 (13:08 +0900)
committerDan Mihai <Daniel.Mihai@microsoft.com>
Thu, 8 Dec 2016 18:22:18 +0000 (18:22 +0000)
- add socket fd initialization after closing TCP session in tcpserver

Change-Id: Icb40f0c37ccc17ee9972974cfeae752e3a60048d
Signed-off-by: Minji Park <minjii.park@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/14499
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: jihwan seo <jihwan.seo@samsung.com>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
Signed-off-by: Jaehong Jo <jaehong.jo@samsung.com>
Signed-off-by: hyuna0213.jo <hyuna0213.jo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/14777
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
resource/csdk/connectivity/src/tcp_adapter/catcpserver.c

index 4d872a0..a25ea76 100644 (file)
@@ -315,7 +315,10 @@ static void CASelectReturned(fd_set *readFds)
                 if (FD_ISSET(svritem->fd, readFds))
                 {
                     CAReceiveMessage(svritem->fd);
-                    FD_CLR(svritem->fd, readFds);
+                    if (-1 != svritem->fd)
+                    {
+                        FD_CLR(svritem->fd, readFds);
+                    }
                 }
             }
         }
@@ -1395,6 +1398,8 @@ CAResult_t CADisconnectTCPSession(CATCPSessionInfo_t *svritem, size_t index)
     }
 
     OICFree(svritem);
+    svritem = NULL;
+
     return CA_STATUS_OK;
 }