xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: Razvan Cojocaru <rcojocaru@bitdefender.com>
Cc: ian.jackson@eu.citrix.com, xen-devel@lists.xen.org,
	Wei Liu <wei.liu2@citrix.com>,
	stefano.stabellini@eu.citrix.com
Subject: Re: [PATCH] tools/xenstore-watch: Add new timeout parameter
Date: Wed, 16 Mar 2016 18:57:59 +0000	[thread overview]
Message-ID: <20160316185759.GA24181@citrix.com> (raw)
In-Reply-To: <56E9AB89.6010404@bitdefender.com>

On Wed, Mar 16, 2016 at 08:52:57PM +0200, Razvan Cojocaru wrote:
> On 03/16/2016 08:46 PM, Wei Liu wrote:
> > 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?
> 
> I don't think so, an EINTR means that a signal has been caught during
> poll() - it's not really a failure case.
> 

What about Ctrl-C ? I think it is reasonable that user want to interrupt
the process.

> > And as others have mentioned, please also patch manpage.
> 
> As Andrew has pointed out, there is no man page to patch. I agree that
> adding one would be great, but I hope this patch can get through without
> it being required - it can be added later.
> 

Yes, follow-up patch is OK.

Wei.

> 
> Thanks,
> Razvan
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel

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

  reply	other threads:[~2016-03-16 18:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-16 15:50 [PATCH] tools/xenstore-watch: Add new timeout parameter Razvan Cojocaru
2016-03-16 17:43 ` Konrad Rzeszutek Wilk
2016-03-16 17:50   ` Andrew Cooper
2016-03-16 18:46 ` Wei Liu
2016-03-16 18:52   ` Razvan Cojocaru
2016-03-16 18:57     ` Wei Liu [this message]
2016-03-16 19:06       ` Razvan Cojocaru

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160316185759.GA24181@citrix.com \
    --to=wei.liu2@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=rcojocaru@bitdefender.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).