From 5276157151d44fe7cf09060b413e81a1420c1b93 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Fri, 6 Sep 2019 11:26:35 +0000 Subject: shutdown protocol now transmits a timeout; move to stopwatch API --- src/shutdown/s6-linux-init-hpr.c | 2 +- src/shutdown/s6-linux-init-shutdown.c | 1 + src/shutdown/s6-linux-init-shutdownd.c | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/shutdown/s6-linux-init-hpr.c b/src/shutdown/s6-linux-init-hpr.c index 6c88b47..265cc30 100644 --- a/src/shutdown/s6-linux-init-hpr.c +++ b/src/shutdown/s6-linux-init-hpr.c @@ -114,7 +114,7 @@ int main (int argc, char const *const *argv) if (dowall) hpr_wall(HPR_WALL_BANNER) ; if (dowtmp < 2) { - if (!hpr_shutdown(what, &STAMP, 0)) + if (!hpr_shutdown(what, &tain_zero, 0)) strerr_diefu1sys(111, "notify s6-linux-init-shutdownd") ; } return 0 ; diff --git a/src/shutdown/s6-linux-init-shutdown.c b/src/shutdown/s6-linux-init-shutdown.c index 306bee0..2a85ba9 100644 --- a/src/shutdown/s6-linux-init-shutdown.c +++ b/src/shutdown/s6-linux-init-shutdown.c @@ -246,6 +246,7 @@ int main (int argc, char const *const *argv) } if (!argc) dieusage() ; parse_time(&when, argv[0]) ; + tain_sub(&when, &when, &STAMP) ; if (argv[1]) hpr_wall(argv[1]) ; if (what < 4) { diff --git a/src/shutdown/s6-linux-init-shutdownd.c b/src/shutdown/s6-linux-init-shutdownd.c index 9707ade..f5c436c 100644 --- a/src/shutdown/s6-linux-init-shutdownd.c +++ b/src/shutdown/s6-linux-init-shutdownd.c @@ -103,6 +103,7 @@ static inline void prepare_shutdown (buffer *b, tain_t *deadline, unsigned int * if (r == -1) strerr_diefu1sys(111, "read from pipe") ; if (r < TAIN_PACK + 4) strerr_dief1x(101, "bad shutdown protocol") ; tain_unpack(pack, deadline) ; + tain_add_g(deadline, deadline) ; uint32_unpack_big(pack + TAIN_PACK, &u) ; if (u && u <= 300000) *grace_time = u ; } @@ -262,7 +263,7 @@ int main (int argc, char const *const *argv, char const *const *envp) if (sig_ignore(SIGPIPE) == -1) strerr_diefu1sys(111, "sig_ignore SIGPIPE") ; buffer_init(&b, &buffer_read, fdr, buf, 64) ; - tain_now_g() ; + tain_now_set_stopwatch_g() ; tain_add_g(&deadline, &tain_infinite_relative) ; for (;;) @@ -300,6 +301,7 @@ int main (int argc, char const *const *argv, char const *const *envp) kill(-1, SIGTERM) ; kill(-1, SIGCONT) ; tain_from_millisecs(&deadline, grace_time) ; + tain_now_g() ; tain_add_g(&deadline, &deadline) ; deepsleepuntil_g(&deadline) ; sync() ; -- cgit v1.2.3