[PATCH 3/3] tools: hv: Check return value of poll call

Tomas Hozza thozza at redhat.com
Thu Jun 27 12:07:43 UTC 2013


----- Original Message -----
> On Thu, Jun 27, 2013 at 5:22 PM, Tomas Hozza <thozza at redhat.com> wrote:
> > 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 at redhat.com>
> > ---
> >  tools/hv/hv_vss_daemon.c | 11 ++++++++++-
> >  1 file changed, 10 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/hv/hv_vss_daemon.c b/tools/hv/hv_vss_daemon.c
> > index 6c4d2f1..826d499 100644
> > --- a/tools/hv/hv_vss_daemon.c
> > +++ b/tools/hv/hv_vss_daemon.c
> > @@ -204,7 +204,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) {
> 
> From the description it seems that this is a typo. It should be 'while'?

It could be. The reason why you think it is a typo is that in this patch
you don't see that the whole code in in a while loop.

<snip>
	...
	while (1) {
		struct sockaddr *addr_p = (struct sockaddr *) &addr;
		socklen_t addr_l = sizeof(addr);
		pfd.events = POLLIN;
		pfd.revents = 0;
		poll(&pfd, 1, -1);
		...
> 
> > +                       syslog(LOG_ERR, "poll failed; error:%d %s", errno,
> > strerror(errno));
> > +                       if (errno == EINVAL) {
> > +                               close(fd);
> > +                               exit(EXIT_FAILURE);
> > +                       }
> > +                       else
> > +                               continue;
> > +               }
> >
> >                 len = recvfrom(fd, vss_recv_buffer,
> >                 sizeof(vss_recv_buffer), 0,
> >                                 addr_p, &addr_l);
> > --
> > 1.8.1.4
> >
> > _______________________________________________
> > devel mailing list
> > devel at linuxdriverproject.org
> > http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
> 
> 
> 
> --
> ~Santosh
> 


More information about the devel mailing list