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

[Xen-devel] Re: [PATCH V3] libxl, Introduce a QMP client



On Wed, 15 Jun 2011, Ian Campbell wrote:
> > +static int qmp_synchronous_send(libxl__qmp_handler *qmp, const char *cmd, 
> > qmp_callback_t callback, int ask_timeout)
> > +{
> > +    int id = 0;
> > +    int ret = 0;
> > +    fd_set rfds;
> > +    struct timeval timeout;
> > +
> > +    id = qmp_send(qmp, cmd, callback);
> > +    if (id <= 0) {
> > +        return -1;
> > +    }
> > +    qmp->wait_for_id = id;
> > +
> > +    timeout.tv_sec = ask_timeout;
> > +    timeout.tv_usec = 0;
> > +
> > +    while (qmp->wait_for_id == id) {
> > +        FD_ZERO(&rfds);
> > +        FD_SET(qmp->qmp_fd, &rfds);
> > +        ret = select(qmp->qmp_fd + 1, &rfds, NULL, NULL, &timeout);
> 
> Linux modifies timeout to reflect the amount of time left, which will
> mean that the timeout shrinks as answers which aren't for us come in.
> You need to init timeout inside the loop. select(2) recommends treating
> timeout as undefined after a select().
> 
> Do we want an overall timeout in case qemu never responds?


if qemu never responds we just need a single timeout inside the loop :)

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

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