[libvirt] [PATCH v4b] Add functions for handling exponential backoff loops.

Martin Kletzander mkletzan at redhat.com
Fri Apr 15 09:44:00 UTC 2016


On Fri, Apr 15, 2016 at 10:27:31AM +0100, Richard W.M. Jones wrote:
>On Fri, Apr 15, 2016 at 11:17:03AM +0200, Martin Kletzander wrote:
>> I'm not keeping up with these patches, but why don't we have one
>> function that initializes the @timeout on it's first run based on the
>> parameters?  Actually, it would just use the timeout to keep one number,
>> so it could be uint or something.  You could then basically do:
>>
>>  while (virBackOffWait(&timeout, 1, 3000))
>
>You would still need to initialize the timeout variable
>somehow, since (in C):
>
>  virTimeBackOffVar var;
>

virTimeBackOffVar var = {0};

would do, and then there's the option for doing
VIR_TIME_BACKOFF_INITIALIZER, but I agree that it's better to call the
initialization function.

Anyway, I like this (b) version of the patch a bit more, if that counts
at all ;)

>  while (virTimeBackOffWhile(&var, 1, 3000)) {
>    //...
>  }
>
>... there's no way to tell if it's the first run of the loop or not.
>
>Given that you have to initialize 'var' somewhere, you might as well
>have the virTimeBackOffStart function as in patch 4b.
>
>Rich.
>
>--
>Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
>Read my programming and virtualization blog: http://rwmj.wordpress.com
>virt-p2v converts physical machines to virtual machines.  Boot with a
>live CD or over the network (PXE) and turn machines into KVM guests.
>http://libguestfs.org/virt-v2v
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20160415/91d42196/attachment-0001.sig>


More information about the libvir-list mailing list