- tools: hv: Improve error logging in VSS daemon.
[opensuse:kernel-source.git] / patches.suse / msft-hv-0528-tools-hv-Check-return-value-of-poll-call.patch
1 From: Tomas Hozza <thozza@redhat.com>
2 Date: Thu, 27 Jun 2013 13:52:49 +0200
3 Patch-mainline: v3.12-rc1
4 Subject: tools: hv: Check return value of poll call
5 Git-commit: 9561d479314f16b41563f73511fb61d91de4642f
6
7 Check return value of poll call and if it fails print error to the
8 system log. If errno is EINVAL then exit with non-zero value otherwise
9 continue the while loop and call poll again.
10
11 Signed-off-by: Tomas Hozza <thozza@redhat.com>
12 Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
13 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
14 Acked-by: <ohering@suse.de>
15 ---
16  tools/hv/hv_vss_daemon.c | 11 ++++++++++-
17  1 file changed, 10 insertions(+), 1 deletion(-)
18
19 diff --git a/tools/hv/hv_vss_daemon.c b/tools/hv/hv_vss_daemon.c
20 index 64112e1..5febe35 100644
21 --- a/tools/hv/hv_vss_daemon.c
22 +++ b/tools/hv/hv_vss_daemon.c
23 @@ -200,7 +200,16 @@ int main(void)
24                 socklen_t addr_l = sizeof(addr);
25                 pfd.events = POLLIN;
26                 pfd.revents = 0;
27 -               poll(&pfd, 1, -1);
28 +
29 +               if (poll(&pfd, 1, -1) < 0) {
30 +                       syslog(LOG_ERR, "poll failed; error:%d %s", errno, strerror(errno));
31 +                       if (errno == EINVAL) {
32 +                               close(fd);
33 +                               exit(EXIT_FAILURE);
34 +                       }
35 +                       else
36 +                               continue;
37 +               }
38  
39                 len = recvfrom(fd, vss_recv_buffer, sizeof(vss_recv_buffer), 0,
40                                 addr_p, &addr_l);