[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] tools/xenstore-watch: Add new timeout parameter



On Wed, Mar 16, 2016 at 05:50:46PM +0200, Razvan Cojocaru wrote:
[...]
>  }
>  
> @@ -273,27 +274,49 @@ do_chmod(char *path, struct xs_permissions *perms, int 
> nperms, int upto,
>  }
>  
>  static void
> -do_watch(struct xs_handle *xsh, int max_events)
> +do_watch(struct xs_handle *xsh, int max_events, int timeout)
>  {
> -    int count = 0;
> +    int rc, ms_timeout = timeout * 1000;
>      char **vec = NULL;
> +    struct pollfd fd;
>  
> -    for ( count = 0; max_events == -1 || count < max_events; count++ ) {
> -     unsigned int num;
> +    fd.fd = xs_fileno(xsh);
> +    fd.events = POLLIN | POLLERR;
>  
> -     vec = xs_read_watch(xsh, &num);
> -     if (vec == NULL)
> -         continue;
> +    do {
> +        rc = poll(&fd, 1, 100);
>  
> -     printf("%s\n", vec[XS_WATCH_PATH]);
> -     fflush(stdout);
> -     free(vec);
> -    }
> +        if (rc == 0 || (rc < 0 && errno == EINTR)) {
> +            ms_timeout -= 100;

Shouldn't you just exit the loop when getting EINTR?

And as others have mentioned, please also patch manpage.

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.