summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2019-09-04 17:52:22 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2019-09-04 17:52:22 +0000
commit2f8e7b245b7fe187c41ea3655fce7551cfd7a48c (patch)
tree7cab69ff654641d465353e5c04d9e6d6aa813e8e /src
parenta359fda48970b7d02ef914e3f7aa0a9c9ff73f7f (diff)
downloads6-2f8e7b245b7fe187c41ea3655fce7551cfd7a48c.tar.xz
Separate wall clocks from stopwatches
Diffstat (limited to 'src')
-rw-r--r--src/conn-tools/s6-ioconnect.c1
-rw-r--r--src/conn-tools/s6-sudoc.c1
-rw-r--r--src/conn-tools/s6-sudod.c1
-rw-r--r--src/daemontools-extras/s6-log.c28
-rw-r--r--src/daemontools-extras/s6-setlock.c1
-rw-r--r--src/fdholder/s6-fdholder-delete.c1
-rw-r--r--src/fdholder/s6-fdholder-getdump.c1
-rw-r--r--src/fdholder/s6-fdholder-list.c1
-rw-r--r--src/fdholder/s6-fdholder-retrieve.c1
-rw-r--r--src/fdholder/s6-fdholder-setdump.c1
-rw-r--r--src/fdholder/s6-fdholder-store.c1
-rw-r--r--src/fdholder/s6-fdholder-transferdump.c1
-rw-r--r--src/fdholder/s6-fdholderd.c3
-rw-r--r--src/libs6/s6-ftrigrd.c1
-rw-r--r--src/libs6/s6lockd.c3
-rw-r--r--src/pipe-tools/s6-ftrig-listen.c1
-rw-r--r--src/pipe-tools/s6-ftrig-listen1.c1
-rw-r--r--src/pipe-tools/s6-ftrig-wait.c1
-rw-r--r--src/supervision/s6-notifyoncheck.c1
-rw-r--r--src/supervision/s6-permafailon.c2
-rw-r--r--src/supervision/s6-supervise.c11
-rw-r--r--src/supervision/s6-svlisten.c1
-rw-r--r--src/supervision/s6-svlisten1.c1
-rw-r--r--src/supervision/s6-svscan.c1
-rw-r--r--src/supervision/s6-svstat.c2
-rw-r--r--src/supervision/s6-svwait.c1
26 files changed, 50 insertions, 19 deletions
diff --git a/src/conn-tools/s6-ioconnect.c b/src/conn-tools/s6-ioconnect.c
index 05a3fdf..49d682c 100644
--- a/src/conn-tools/s6-ioconnect.c
+++ b/src/conn-tools/s6-ioconnect.c
@@ -106,6 +106,7 @@ int main (int argc, char const *const *argv)
if (!iobuffer_init(&b[i], a[i][0].fd, a[i][1].fd)) strerr_diefu1sys(111, "iobuffer_init") ;
}
if (sig_ignore(SIGPIPE) == -1) strerr_diefu1sys(111, "sig_ignore") ;
+ tain_now_set_stopwatch() ;
tain_now_g() ;
x[0].fd = selfpipe_init() ;
if (x[0].fd < 0) strerr_diefu1sys(111, "selfpipe_init") ;
diff --git a/src/conn-tools/s6-sudoc.c b/src/conn-tools/s6-sudoc.c
index d46e398..79d32f0 100644
--- a/src/conn-tools/s6-sudoc.c
+++ b/src/conn-tools/s6-sudoc.c
@@ -53,6 +53,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
if (!fd_sanitize() || !fd_ensure_open(2, 1))
strerr_diefu1sys(111, "sanitize stdin/stdout/stderr") ;
+ tain_now_set_stopwatch() ;
tain_now_g() ;
tain_add_g(&deadline, &deadline) ;
{
diff --git a/src/conn-tools/s6-sudod.c b/src/conn-tools/s6-sudod.c
index a7c5668..9cc7148 100644
--- a/src/conn-tools/s6-sudod.c
+++ b/src/conn-tools/s6-sudod.c
@@ -55,6 +55,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
if ((ndelay_on(0) < 0) || (ndelay_on(1) < 0))
strerr_diefu1sys(111, "make socket non-blocking") ;
+ tain_now_set_stopwatch() ;
tain_now_g() ;
tain_add_g(&deadline, &deadline) ;
buffer_putnoflush(buffer_1small, S6_SUDO_BANNERB, S6_SUDO_BANNERB_LEN) ;
diff --git a/src/daemontools-extras/s6-log.c b/src/daemontools-extras/s6-log.c
index 16f6dd1..5477298 100644
--- a/src/daemontools-extras/s6-log.c
+++ b/src/daemontools-extras/s6-log.c
@@ -898,18 +898,23 @@ static void script_run (scriptelem_t const *script, unsigned int scriptlen, char
size_t hlen = 0 ;
char hstamp[32] ;
char tstamp[TIMESTAMP+1] ;
- if (gflags & 1)
+ if (gflags & 3)
{
- timestamp_g(tstamp) ;
- tstamp[TIMESTAMP] = ' ' ;
- }
- if (gflags & 2)
- {
- localtmn_t l ;
- localtmn_from_tain_g(&l, 1) ;
- hlen = localtmn_fmt(hstamp, &l) ;
- hstamp[hlen++] = ' ' ;
- hstamp[hlen++] = ' ' ;
+ tain_t now ;
+ tain_wallclock_read(&now) ;
+ if (gflags & 1)
+ {
+ timestamp_fmt(tstamp, &now) ;
+ tstamp[TIMESTAMP] = ' ' ;
+ }
+ if (gflags & 2)
+ {
+ localtmn_t l ;
+ localtmn_from_tain(&l, &now, 1) ;
+ hlen = localtmn_fmt(hstamp, &l) ;
+ hstamp[hlen++] = ' ' ;
+ hstamp[hlen++] = ' ' ;
+ }
}
for (; i < scriptlen ; i++)
@@ -1179,6 +1184,7 @@ int main (int argc, char const *const *argv)
if (linelimit && linelimit < LINELIMIT_MIN) linelimit = LINELIMIT_MIN ;
if (compat_gflags && verbosity) strerr_warnw1x("options -t and -e are deprecated") ;
if (!fd_sanitize()) strerr_diefu1sys(111, "ensure stdin/stdout/stderr are open") ;
+ tain_now_set_stopwatch() ; /* only for timeouts; wallclock is used for timestamping */
if (!tain_now_g() && verbosity) strerr_warnwu1sys("read current time - timestamps may be wrong for a while") ;
if (ndelay_on(0) < 0) strerr_diefu3sys(111, "set std", "in", " non-blocking") ;
if (ndelay_on(1) < 0) strerr_diefu3sys(111, "set std", "out", " non-blocking") ;
diff --git a/src/daemontools-extras/s6-setlock.c b/src/daemontools-extras/s6-setlock.c
index 4bd4d14..a07c0e4 100644
--- a/src/daemontools-extras/s6-setlock.c
+++ b/src/daemontools-extras/s6-setlock.c
@@ -57,6 +57,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
int p[2] = { 0, 1 } ;
pid_t pid ;
char c ;
+ tain_now_set_stopwatch() ;
tain_now_g() ;
tain_from_millisecs(&deadline, timeout) ;
tain_add_g(&deadline, &deadline) ;
diff --git a/src/fdholder/s6-fdholder-delete.c b/src/fdholder/s6-fdholder-delete.c
index 09d3a2c..2a50b79 100644
--- a/src/fdholder/s6-fdholder-delete.c
+++ b/src/fdholder/s6-fdholder-delete.c
@@ -32,6 +32,7 @@ int main (int argc, char const *const *argv)
else deadline = tain_infinite_relative ;
}
if (argc < 2) dieusage() ;
+ tain_now_set_stopwatch() ;
tain_now_g() ;
tain_add_g(&deadline, &deadline) ;
if (!s6_fdholder_start_g(&a, argv[0], &deadline))
diff --git a/src/fdholder/s6-fdholder-getdump.c b/src/fdholder/s6-fdholder-getdump.c
index 89069e9..7b45124 100644
--- a/src/fdholder/s6-fdholder-getdump.c
+++ b/src/fdholder/s6-fdholder-getdump.c
@@ -39,6 +39,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
}
if (argc < 2) dieusage() ;
+ tain_now_set_stopwatch() ;
tain_now_g() ;
tain_add_g(&deadline, &deadline) ;
if (!s6_fdholder_start_g(&a, argv[0], &deadline))
diff --git a/src/fdholder/s6-fdholder-list.c b/src/fdholder/s6-fdholder-list.c
index d6981d0..2be3a25 100644
--- a/src/fdholder/s6-fdholder-list.c
+++ b/src/fdholder/s6-fdholder-list.c
@@ -40,6 +40,7 @@ int main (int argc, char const *const *argv)
}
if (!argc) dieusage() ;
+ tain_now_set_stopwatch() ;
tain_now_g() ;
tain_add_g(&deadline, &deadline) ;
if (!s6_fdholder_start_g(&a, argv[0], &deadline))
diff --git a/src/fdholder/s6-fdholder-retrieve.c b/src/fdholder/s6-fdholder-retrieve.c
index dacc072..c6ce4ee 100644
--- a/src/fdholder/s6-fdholder-retrieve.c
+++ b/src/fdholder/s6-fdholder-retrieve.c
@@ -37,6 +37,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
}
if (argc < 3) dieusage() ;
+ tain_now_set_stopwatch() ;
tain_now_g() ;
tain_add_g(&deadline, &deadline) ;
if (!s6_fdholder_start_g(&a, argv[0], &deadline))
diff --git a/src/fdholder/s6-fdholder-setdump.c b/src/fdholder/s6-fdholder-setdump.c
index 41a1c07..3265997 100644
--- a/src/fdholder/s6-fdholder-setdump.c
+++ b/src/fdholder/s6-fdholder-setdump.c
@@ -40,6 +40,7 @@ int main (int argc, char const *const *argv)
x = getenv("S6_FD#") ;
if (!x) strerr_dienotset(100, "S6_FD#") ;
if (!uint0_scan(x, &dumplen)) strerr_dieinvalid(100, "S6_FD#") ;
+ tain_now_set_stopwatch() ;
tain_now_g() ;
tain_add_g(&deadline, &deadline) ;
if (!s6_fdholder_start_g(&a, argv[0], &deadline))
diff --git a/src/fdholder/s6-fdholder-store.c b/src/fdholder/s6-fdholder-store.c
index 75510d2..bc221cd 100644
--- a/src/fdholder/s6-fdholder-store.c
+++ b/src/fdholder/s6-fdholder-store.c
@@ -38,6 +38,7 @@ int main (int argc, char const *const *argv)
}
if (argc < 2) dieusage() ;
+ tain_now_set_stopwatch() ;
tain_now_g() ;
tain_add_g(&deadline, &deadline) ;
tain_add_g(&limit, &limit) ;
diff --git a/src/fdholder/s6-fdholder-transferdump.c b/src/fdholder/s6-fdholder-transferdump.c
index 83d1e80..d7730a9 100644
--- a/src/fdholder/s6-fdholder-transferdump.c
+++ b/src/fdholder/s6-fdholder-transferdump.c
@@ -53,6 +53,7 @@ int main (int argc, char const *const *argv)
}
if (argc < 2) dieusage() ;
+ tain_now_set_stopwatch() ;
tain_now_g() ;
tain_add_g(&deadline, &deadline) ;
if (!s6_fdholder_start_g(&a, argv[0], &deadline))
diff --git a/src/fdholder/s6-fdholderd.c b/src/fdholder/s6-fdholderd.c
index 86a957a..47e1f17 100644
--- a/src/fdholder/s6-fdholderd.c
+++ b/src/fdholder/s6-fdholderd.c
@@ -762,6 +762,9 @@ int main (int argc, char const *const *argv, char const *const *envp)
fd_write(1, "\n", 1) ;
fd_close(1) ;
}
+
+ /* We are long-lived and have to check absolute fd deadlines,
+ so we purposefully remain in wallclock mode. */
tain_now_g() ;
for (;;)
diff --git a/src/libs6/s6-ftrigrd.c b/src/libs6/s6-ftrigrd.c
index dfb9672..ce9d03a 100644
--- a/src/libs6/s6-ftrigrd.c
+++ b/src/libs6/s6-ftrigrd.c
@@ -201,6 +201,7 @@ int main (void)
{
tain_t deadline ;
+ tain_now_set_stopwatch() ;
tain_now_g() ;
tain_addsec_g(&deadline, 2) ;
if (!textclient_server_01x_init_g(FTRIGR_BANNER1, FTRIGR_BANNER1_LEN, FTRIGR_BANNER2, FTRIGR_BANNER2_LEN, &deadline))
diff --git a/src/libs6/s6lockd.c b/src/libs6/s6lockd.c
index 5e0b30c..d2f76d5 100644
--- a/src/libs6/s6lockd.c
+++ b/src/libs6/s6lockd.c
@@ -203,7 +203,8 @@ int main (int argc, char const *const *argv)
if (selfpipe_trapset(&set) < 0)
strerr_diefu1sys(111, "trap signals") ;
}
-
+
+ tain_now_set_stopwatch() ;
tain_now_g() ;
tain_addsec_g(&deadline, 2) ;
diff --git a/src/pipe-tools/s6-ftrig-listen.c b/src/pipe-tools/s6-ftrig-listen.c
index f0ef2bf..582e60c 100644
--- a/src/pipe-tools/s6-ftrig-listen.c
+++ b/src/pipe-tools/s6-ftrig-listen.c
@@ -59,6 +59,7 @@ int main (int argc, char const **argv, char const *const *envp)
argc1 = el_semicolon(argv) ;
if (!argc1 || (argc1 & 1) || (argc == argc1 + 1)) dieusage() ;
if (argc1 >= argc) strerr_dief1x(100, "unterminated fifodir+regex block") ;
+ tain_now_set_stopwatch() ;
tain_now_g() ;
tain_add_g(&deadline, &tto) ;
x[0].fd = selfpipe_init() ;
diff --git a/src/pipe-tools/s6-ftrig-listen1.c b/src/pipe-tools/s6-ftrig-listen1.c
index 731b1e3..1acaf6b 100644
--- a/src/pipe-tools/s6-ftrig-listen1.c
+++ b/src/pipe-tools/s6-ftrig-listen1.c
@@ -55,6 +55,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
}
if (argc < 3) strerr_dieusage(100, USAGE) ;
+ tain_now_set_stopwatch() ;
tain_now_g() ;
tain_add_g(&deadline, &tto) ;
diff --git a/src/pipe-tools/s6-ftrig-wait.c b/src/pipe-tools/s6-ftrig-wait.c
index 5aca73c..1e852db 100644
--- a/src/pipe-tools/s6-ftrig-wait.c
+++ b/src/pipe-tools/s6-ftrig-wait.c
@@ -36,6 +36,7 @@ int main (int argc, char const *const *argv)
}
if (argc < 2) strerr_dieusage(100, USAGE) ;
+ tain_now_set_stopwatch() ;
tain_now_g() ;
tain_add_g(&deadline, &tto) ;
diff --git a/src/supervision/s6-notifyoncheck.c b/src/supervision/s6-notifyoncheck.c
index b484da9..71489ea 100644
--- a/src/supervision/s6-notifyoncheck.c
+++ b/src/supervision/s6-notifyoncheck.c
@@ -140,6 +140,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
if (fcntl(fd, F_GETFD) < 0)
strerr_dief2sys(111, "notification-fd", " sanity check failed") ;
+ tain_now_set_stopwatch() ;
tain_now_g() ;
tain_add_g(&globaldeadline, &globaldeadline) ;
diff --git a/src/supervision/s6-permafailon.c b/src/supervision/s6-permafailon.c
index f242afd..91df73d 100644
--- a/src/supervision/s6-permafailon.c
+++ b/src/supervision/s6-permafailon.c
@@ -95,7 +95,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
tain_uint(&mintime, seconds) ;
{
tain_t now ;
- tain_now(&now) ;
+ tain_wallclock_read(&now) ;
tain_sub(&mintime, &now, &mintime) ;
}
diff --git a/src/supervision/s6-supervise.c b/src/supervision/s6-supervise.c
index 6dd815e..dd5025e 100644
--- a/src/supervision/s6-supervise.c
+++ b/src/supervision/s6-supervise.c
@@ -109,7 +109,7 @@ static void set_down_and_ready (char const *s, unsigned int n)
status.pid = 0 ;
status.flagfinishing = 0 ;
status.flagready = 1 ;
- tain_copynow(&status.readystamp) ;
+ tain_wallclock_read(&status.readystamp) ;
state = DOWN ;
if (tain_future(&dontrespawnbefore)) deadline = dontrespawnbefore ;
else tain_copynow(&deadline) ;
@@ -310,7 +310,7 @@ static void trystart (void)
state = UP ;
status.pid = pid ;
status.flagready = 0 ;
- tain_copynow(&status.stamp) ;
+ tain_wallclock_read(&status.stamp) ;
tain_addsec_g(&dontrespawnbefore, 1) ;
announce() ;
ftrigw_notifyb_nosig(S6_SUPERVISE_EVENTDIR, "u", 1) ;
@@ -354,7 +354,7 @@ static int uplastup_z (void)
status.flagready = 0 ;
status.flagthrottled = 0 ;
flagdying = 0 ;
- tain_copynow(&status.stamp) ;
+ tain_wallclock_read(&status.stamp) ;
if (notifyfd >= 0)
{
fd_close(notifyfd) ;
@@ -559,7 +559,7 @@ static inline void handle_notifyfd (void)
r = sanitize_read(fd_read(notifyfd, buf, 4096)) ;
if (r > 0 && memchr(buf, '\n', r))
{
- tain_copynow(&status.readystamp) ;
+ tain_wallclock_read(&status.readystamp) ;
status.flagready = 1 ;
announce() ;
ftrigw_notifyb_nosig(S6_SUPERVISE_EVENTDIR, "U", 1) ;
@@ -669,9 +669,10 @@ int main (int argc, char const *const *argv)
else if (errno != ENOENT)
strerr_diefu1sys(111, "access ./down") ;
+ tain_now_set_stopwatch() ;
tain_now_g() ;
settimeout(0) ;
- tain_copynow(&status.stamp) ;
+ tain_wallclock_read(&status.stamp) ;
status.readystamp = status.stamp ;
announce() ;
ftrigw_notifyb_nosig(S6_SUPERVISE_EVENTDIR, "s", 1) ;
diff --git a/src/supervision/s6-svlisten.c b/src/supervision/s6-svlisten.c
index e44ba87..2ce08cf 100644
--- a/src/supervision/s6-svlisten.c
+++ b/src/supervision/s6-svlisten.c
@@ -56,6 +56,7 @@ int main (int argc, char const **argv, char const *const *envp)
strerr_warnw3x("-o is unsupported when combined with -", wantready ? "R" : "r", "- using -a instead") ;
}
+ tain_now_set_stopwatch() ;
tain_now_g() ;
tain_add_g(&deadline, &tto) ;
spfd = s6_svlisten_selfpipe_init() ;
diff --git a/src/supervision/s6-svlisten1.c b/src/supervision/s6-svlisten1.c
index 69d8ac7..d38d771 100644
--- a/src/supervision/s6-svlisten1.c
+++ b/src/supervision/s6-svlisten1.c
@@ -45,6 +45,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
if (t) tain_from_millisecs(&tto, t) ; else tto = tain_infinite_relative ;
}
if (argc < 2) dieusage() ;
+ tain_now_set_stopwatch() ;
tain_now_g() ;
tain_add_g(&deadline, &tto) ;
spfd = s6_svlisten_selfpipe_init() ;
diff --git a/src/supervision/s6-svscan.c b/src/supervision/s6-svscan.c
index 4228a21..4d00743 100644
--- a/src/supervision/s6-svscan.c
+++ b/src/supervision/s6-svscan.c
@@ -520,6 +520,7 @@ int main (int argc, char const *const *argv)
{
struct svinfo_s blob[max] ; /* careful with that stack, Eugene */
services = blob ;
+ tain_now_set_stopwatch() ; /* now try a backwards clock jump, bitch */
tain_now_g() ;
diff --git a/src/supervision/s6-svstat.c b/src/supervision/s6-svstat.c
index d46c60a..7c93138 100644
--- a/src/supervision/s6-svstat.c
+++ b/src/supervision/s6-svstat.c
@@ -274,7 +274,7 @@ int main (int argc, char const *const *argv)
if (!s6_svstatus_read(argv[0], &status))
strerr_diefu2sys(111, "read status for ", argv[0]) ;
- tain_now_g() ;
+ tain_wallclock_read_g() ;
if (tain_future(&status.stamp)) tain_copynow(&status.stamp) ;
{
diff --git a/src/supervision/s6-svwait.c b/src/supervision/s6-svwait.c
index f2bd34c..cda3591 100644
--- a/src/supervision/s6-svwait.c
+++ b/src/supervision/s6-svwait.c
@@ -41,6 +41,7 @@ int main (int argc, char const *const *argv)
}
if (!argc) dieusage() ;
+ tain_now_set_stopwatch() ;
tain_now_g() ;
tain_add_g(&deadline, &tto) ;