From: Anthony PERARD <anthony.perard@citrix.com>
To: Wei Liu <wei.liu2@citrix.com>
Cc: Xen devel <xen-devel@lists.xenproject.org>,
Ian Jackson <Ian.Jackson@eu.citrix.com>,
Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
Subject: Re: [PATCH] libxl/libxl_qmp.c: Fix code style in qmp_next()
Date: Wed, 4 Jan 2017 17:56:25 +0000 [thread overview]
Message-ID: <20170104175625.GA1903@perard.uk.xensource.com> (raw)
In-Reply-To: <20161222104734.GL28690@citrix.com>
On Thu, Dec 22, 2016 at 10:47:35AM +0000, Wei Liu wrote:
> On Thu, Dec 22, 2016 at 05:53:07PM +0800, Zhang Chen wrote:
> > diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c
> > index ad22ad4..123a6bf 100644
> > --- a/tools/libxl/libxl_qmp.c
> > +++ b/tools/libxl/libxl_qmp.c
> > @@ -427,79 +427,78 @@ static int qmp_next(libxl__gc *gc, libxl__qmp_handler *qmp)
> > size_t incomplete_size = 0;
> > int rc = 0;
> >
> > - do {
> > - fd_set rfds;
> > - int ret = 0;
> > - struct timeval timeout = {
> > - .tv_sec = qmp->timeout,
> > - .tv_usec = 0,
> > - };
> > + fd_set rfds;
> > + int ret = 0;
> > + struct timeval timeout = {
> > + .tv_sec = qmp->timeout,
> > + .tv_usec = 0,
> > + };
> >
> > - FD_ZERO(&rfds);
> > - FD_SET(qmp->qmp_fd, &rfds);
> > + FD_ZERO(&rfds);
> > + FD_SET(qmp->qmp_fd, &rfds);
> >
> > + do {
> > ret = select(qmp->qmp_fd + 1, &rfds, NULL, NULL, &timeout);
> > - if (ret == 0) {
> > - LOGD(ERROR, qmp->domid, "timeout");
> > - return -1;
> > - } else if (ret < 0) {
> > - if (errno == EINTR)
> > - continue;
> > - LOGED(ERROR, qmp->domid, "Select error");
> > - return -1;
> > - }
> > + } while (ret == -1 && errno == EINTR);
> >
>
> A side note.
>
> Select may modify timeout, so I think we need to reset timeout at the
> beginning of the loop.
>
rfds is also modified by select() and needs to be reset before calling
select again.
--
Anthony PERARD
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
prev parent reply other threads:[~2017-01-04 17:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-22 9:53 [PATCH] libxl/libxl_qmp.c: Fix code style in qmp_next() Zhang Chen
2016-12-22 10:47 ` Wei Liu
2016-12-23 3:16 ` Zhang Chen
2016-12-23 11:44 ` Wei Liu
2016-12-26 6:48 ` Zhang Chen
2017-01-04 17:56 ` Anthony PERARD [this message]
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=20170104175625.GA1903@perard.uk.xensource.com \
--to=anthony.perard@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
--cc=zhangchen.fnst@cn.fujitsu.com \
/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).