Crash in Select 95/216595/2
authorsourav bhuwalka <s.bhuwalka@samsung.com>
Mon, 14 Oct 2019 16:27:56 +0000 (21:57 +0530)
committerSudipto <sudipto.bal@samsung.com>
Tue, 29 Oct 2019 09:40:51 +0000 (15:10 +0530)
Fixing bug in counter of CAPollReturned in case of shutdownFds socket
for ipserver and also introducing sleep between each subsequent
poll system call whenever the system remains idle.

https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/583/commits/817a3e30d2c7f2fa6064cdfd13fc8a9294a5d956
(cherry-picked from 817a3e30d2c7f2fa6064cdfd13fc8a9294a5d956)

Change-Id: I4b6e96334fdb0c06fee2c4ce3099df9bf04ebaf3
Signed-off-by: Sudipto <sudipto.bal@samsung.com>
resource/csdk/connectivity/src/ip_adapter/caipserver.c
resource/csdk/connectivity/src/tcp_adapter/catcpserver.c

index 085f06042235983c9a6e18b20f4ff957e5b5d33e..04a349553f23423fd2f66735432123350b5a8abe 100644 (file)
@@ -362,6 +362,13 @@ static void CAFindReadyMessage()
     {
         CAPollReturned(readFds, ret);
     }
+    else if (ret == 0)
+    {
+        usleep(1000); /* Incase of failure of FastShutdownMechanism timeout will be set to 1.
+                         some of the fields are not set by kernel on repeatedly calling
+                         poll.Applying a sleep will solve this by providing a delay
+                         between each subsequent poll system call */
+    }
     else if (ret < 0)
     {
         OIC_LOG_V(FATAL, TAG, "poll error %s", CAIPS_GET_ERROR);
@@ -398,10 +405,10 @@ static void CAPollReturned(struct pollfd *readFds, int ret)
             // Write end of the pipe is closed. Indicates the termination of UDP server.
             return;
         }
-
-        counter++;
     }
 
+   counter++;
+
     if (!caglobals.ip.terminate &&
            (caglobals.ip.netlinkFd != OC_INVALID_SOCKET) && readFds[counter].revents != 0)
     {
index 081775e304457082b1cd9814bed5f9254342ca03..5b5f92ef9a3f349951f41aa99bfb80b1f5fd925e 100644 (file)
@@ -349,7 +349,8 @@ static void CAFindReadyMessage()
     else if (ret == 0)
     {
         usleep(1000); /* some of the fields are not set by kernel on repeatedly calling
-                         poll.Applying a timeout will solve this*/
+                         poll.Applying a sleep will solve this by providing a delay between
+                         each subsequent poll system call */
     }
     else if (ret < 0)
     {