WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

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

To: Anthony PERARD <anthony.perard@xxxxxxxxxx>
Subject: Re: [Xen-devel] Re: [PATCH V3] libxl, Introduce a QMP client
From: George Dunlap <George.Dunlap@xxxxxxxxxxxxx>
Date: Thu, 16 Jun 2011 11:57:35 +0100
Cc: Ian Campbell <Ian.Campbell@xxxxxxxxxxxxx>, Xen Devel <xen-devel@xxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <Stefano.Stabellini@xxxxxxxxxxxxx>
Delivery-date: Thu, 16 Jun 2011 03:59:52 -0700
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=dpjcaNkJWVyD4ebeiTHGG7S7eHqOXbQIIiaZ242O210=; b=edGdpK9XJfuU9/jrDMauyhYQANtBChIKvaNa6qK33xliSyg/WVzlMROPEBD9+pwVWJ bxXKFRubdCZswGcTxxQcydDKsp2lS+zScwZHm2uJSL2Isp2kP9mBs+s4akEkUx65AH6v 3nTzZ5W2p/VPgYDJopSgIeEkgml7pAApcPcX8=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=xGZAXIGEA7aaigaBiwMTPEVwv3WHrnfNFiaHJKbFjOuVecgBfZUcSlEmgkWr1UXrOz wSJ+LzfWUEEeWIMRvi02AoNF5Oyk30sTRCPvwVSPlM0xqnnDi2jJcBLlc06NyoRUb1lB /Nh26V49Funh9QTUM6d0mTONhcNSgy2u9pqHA=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <BANLkTinYNdg8OrCSAmib3zruOAOQC-0UJg@xxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <1308071754-29014-1-git-send-email-anthony.perard@xxxxxxxxxx> <1308132267.17937.162.camel@xxxxxxxxxxxxxxxxxxxxxx> <BANLkTinYNdg8OrCSAmib3zruOAOQC-0UJg@xxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Wed, Jun 15, 2011 at 7:44 PM, Anthony PERARD
<anthony.perard@xxxxxxxxxx> wrote:
>>> +    do {
>>> +        ret = connect(qmp->qmp_fd, (struct sockaddr *) &qmp->addr,
>>> +                      sizeof (qmp->addr));
>>> +        if (ret == 0)
>>> +            break;
>>> +        if (errno == ENOENT || errno == ECONNREFUSED) {
>>> +            /* ENOENT       : Socket may not have shown up yet
>>> +             * ECONNREFUSED : Leftover socket hasn't been removed yet */
>>> +            continue;
>>> +        }
>>> +        return -1;
>>> +    } while ((++i <= timeout * 5) && (usleep(.2 * 1000000) <= 0));
>>
>> usleep (effectively) takes an unsigned int, what typedoes .2 * x become?
>
> It should be a float. But have 0.2 * 10^6 will be better to understand
> that we have 0.2 second of sleep, but not power in C. If you prefere,
> I will just wrote 200000, should be OK.

I think the standard way for making things like this more readable is
something like:

#define MS (1000)
...
usleep(200 * MS);

But if there's only one sleep, it's probably bike-shedding either way.

 -George

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