Commit 75867ef1 by Yuto KAWAMURA(kawamuray) Committed by Stéphane Graber

Fix incorrect timeout handling of do_reboot_and_check()

Currently do_reboot_and_check() is decreasing timeout variable even if it is set to -1, so running 'lxc-stop --reboot --timeout=-1 ...' will exits immediately at end of second iteration of loop, without waiting container reboot. Also, there is no need to call gettimeofday if timeout is set to -1, so these statements should be evaluated only when timeout is enabled. Signed-off-by: 's avatarYuto KAWAMURA(kawamuray) <kawamuray.dadada@gmail.com> Acked-by: 's avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
parent 9f9e8eb3
...@@ -110,19 +110,23 @@ static int do_reboot_and_check(struct lxc_arguments *a, struct lxc_container *c) ...@@ -110,19 +110,23 @@ static int do_reboot_and_check(struct lxc_arguments *a, struct lxc_container *c)
if (newpid != -1 && newpid != pid) if (newpid != -1 && newpid != pid)
return 0; return 0;
ret = gettimeofday(&tv, NULL); if (timeout != -1) {
if (ret) ret = gettimeofday(&tv, NULL);
break; if (ret)
curtime = tv.tv_sec; break;
curtime = tv.tv_sec;
}
sleep(1); sleep(1);
ret = gettimeofday(&tv, NULL); if (timeout != -1) {
if (ret) ret = gettimeofday(&tv, NULL);
break; if (ret)
elapsed_time = tv.tv_sec - curtime; break;
if (timeout != -1 && timeout - elapsed_time <= 0) elapsed_time = tv.tv_sec - curtime;
break; if (timeout - elapsed_time <= 0)
timeout -= elapsed_time; break;
timeout -= elapsed_time;
}
} }
out: out:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment