Check if policy backend descriptor is set 64/81464/3
authorZbigniew Jasinski <z.jasinski@samsung.com>
Tue, 26 Jul 2016 10:00:37 +0000 (12:00 +0200)
committerZbigniew Jasinski <z.jasinski@samsung.com>
Tue, 2 Aug 2016 09:21:33 +0000 (02:21 -0700)
We need to check if policy backend descriptor is set before we even
check if it's ready for reading/writing.

Change-Id: I35d414ff8723089ecb552d944382c808d618d215
Signed-off-by: Zbigniew Jasinski <z.jasinski@samsung.com>
src/nether_Manager.cpp

index 28c17c1..af1a793 100644 (file)
@@ -136,32 +136,33 @@ bool NetherManager::process()
 
        for(;;)
        {
-               setupSelectSockets(watchedReadDescriptorsSet, watchedWriteDescriptorsSet, timeoutSpecification);
-
-               if(select(FD_SETSIZE, &watchedReadDescriptorsSet, &watchedWriteDescriptorsSet, NULL, &timeoutSpecification) < 0)
-               {
-                       LOGE("select error " << strerror(errno));
-                       return (false);
+               setupSelectSockets(watchedReadDescriptorsSet,
+                               watchedWriteDescriptorsSet, timeoutSpecification);
+
+               int ret = TEMP_FAILURE_RETRY(select(FD_SETSIZE, &watchedReadDescriptorsSet,
+                               &watchedWriteDescriptorsSet, NULL, &timeoutSpecification));
+
+               if (ret < 0) {
+                       int err = errno;
+                       LOGE("select error" << strerror(err));
+                       return false;
+               } else if (ret == 0) {
+                       LOGD("select() timeout");
+                       continue;
                }
 
                if(FD_ISSET(signalDescriptor, &watchedReadDescriptorsSet))
-               {
                        handleSignal();
-               }
+
                if(FD_ISSET(netlinkDescriptor, &watchedReadDescriptorsSet))
-               {
                        if(!handleNetlinkpacket())
                                break;
-               }
-               else
-                       if(FD_ISSET(backendDescriptor, &watchedReadDescriptorsSet) || FD_ISSET(backendDescriptor, &watchedWriteDescriptorsSet))
-                       {
-                               netherPrimaryPolicyBackend->processEvents();
-                       }
-                       else
-                       {
-                               LOGD("select() timeout");
-                       }
+
+               if (backendDescriptor == -1)
+                       continue;
+               if (FD_ISSET(backendDescriptor, &watchedReadDescriptorsSet) ||
+                               FD_ISSET(backendDescriptor, &watchedWriteDescriptorsSet))
+                       netherPrimaryPolicyBackend->processEvents();
        }
 
        return (true);