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

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

 



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

Attachment: signature.asc
Description: Digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]