[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH] libxl/libxl_qmp.c: Fix code style in qmp_next()
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@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |