]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
tools: hv: Check return value of poll call
authorTomas Hozza <thozza@redhat.com>
Wed, 22 May 2013 12:54:31 +0000 (14:54 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 3 Jun 2013 21:13:09 +0000 (14:13 -0700)
Check return value of poll call and if it fails print error
to the system log. If errno is EINVAL then exit with non-zero
value otherwise continue the while loop and call poll again.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
Acked-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
tools/hv/hv_kvp_daemon.c

index ae9aa1cd97febc8f3a304aa9d3c59d52d95808e8..81cbb6ecce893d81392ca56343b4c825669b8e5f 100644 (file)
@@ -1490,7 +1490,16 @@ int main(void)
                socklen_t addr_l = sizeof(addr);
                pfd.events = POLLIN;
                pfd.revents = 0;
-               poll(&pfd, 1, -1);
+
+               if (poll(&pfd, 1, -1) < 0) {
+                       syslog(LOG_ERR, "poll failed; error: %d %s", errno, strerror(errno));
+                       if (errno == EINVAL) {
+                               close(fd);
+                               exit(EXIT_FAILURE);
+                       }
+                       else
+                               continue;
+               }
 
                len = recvfrom(fd, kvp_recv_buffer, sizeof(kvp_recv_buffer), 0,
                                addr_p, &addr_l);