On 01/22/2016 05:32 PM, Dietmar Maurer wrote:
As sleep returns the seconds actually slept we could save the return
value after the sleep call
and only call waitfunc if we slept for $sleep_intervall seconds? or
checking if $! != EINTR.
Or is there a better way?
I usually implement and use a sleep_until() command:
sub sleep_until {
my ($self, $end_time) = @_;
for (;;) {
my $cur_time = time();
last if $cur_time >= $end_time;
CORE::sleep(1);
}
}
I guess you need to adopt that for shorter periods (less that 1 second).
But do we need that here? I mean upid_wait will be called normally from
a forked worker to a longer running task so in the worst case we return
a bit less than a second to late.
Or do you mean that we should also implement the sleep_until in
PVE::Tools? Then yes, there it would be nice to have at least ms or even
µs resolution.
We already have/use that code in src/PVE/HA/Env.pm
Ah yes, true, that code is somehow familiar. Much thanks for the
reminder, will resend.
_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel