Fix for IOT-813
authorTim Kourt <tim.a.kourt@intel.com>
Fri, 16 Oct 2015 17:25:50 +0000 (10:25 -0700)
committerJon A. Cruz <jonc@osg.samsung.com>
Fri, 4 Dec 2015 19:57:38 +0000 (19:57 +0000)
The issue was causing a high battery consumption on Android devices due to
the never blocking loop as a consequence of the CAWakeUpForChange() call.

Change-Id: Ifd4692074430e45b935e0b9c6b6fa4b41a9951f0
Signed-off-by: Tim Kourt <tim.a.kourt@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/3903
Reviewed-by: Jaehong Jo <jaehong.jo@samsung.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Naga Ashok Jampani <jn.ashok@samsung.com>
Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com>
resource/csdk/connectivity/src/ip_adapter/caipserver.c

index 5dd5b87..b50ec75 100644 (file)
@@ -120,7 +120,6 @@ static void CAReceiveHandler(void *data)
 {
     (void)data;
     OIC_LOG(DEBUG, TAG, "IN");
-
     while (!caglobals.ip.terminate)
     {
         CAFindReadyMessage();
@@ -196,8 +195,10 @@ static void CASelectReturned(fd_set *readFds, int ret)
             CAHandleNetlink();
             break;
         }
-        else
+        else if (FD_ISSET(caglobals.ip.shutdownFds[0], readFds))
         {
+            char buf[10];
+            (void)read(caglobals.ip.shutdownFds[0], buf, sizeof (buf));
             CAInterface_t *ifchanged = CAFindInterfaceChange();
             if (ifchanged)
             {
@@ -206,6 +207,10 @@ static void CASelectReturned(fd_set *readFds, int ret)
             }
             break;
         }
+        else
+        {
+            break;
+        }
 
         (void)CAReceiveMessage(fd, flags);
         FD_CLR(fd, readFds);