diff options
-rw-r--r-- | package/deps.mak | 8 | ||||
-rw-r--r-- | src/include/s6/s6-fdholder.h | 1 | ||||
-rw-r--r-- | src/libs6/s6_fdholder_store_async.c | 4 | ||||
-rw-r--r-- | src/supervision/deps-exe/s6-notifywhenup (renamed from src/daemontools-extras/deps-exe/s6-notifywhenup) | 0 | ||||
-rw-r--r-- | src/supervision/s6-notifywhenup.c (renamed from src/daemontools-extras/s6-notifywhenup.c) | 7 | ||||
-rw-r--r-- | src/supervision/s6-svstat.c | 31 |
6 files changed, 36 insertions, 15 deletions
diff --git a/package/deps.mak b/package/deps.mak index 4c5aa5e..8561867 100644 --- a/package/deps.mak +++ b/package/deps.mak @@ -8,7 +8,7 @@ src/include/s6/s6lock.h: src/include/s6/config.h src/conn-tools/s6-accessrules-cdb-from-fs.o src/conn-tools/s6-accessrules-cdb-from-fs.lo: src/conn-tools/s6-accessrules-cdb-from-fs.c src/conn-tools/s6-accessrules-fs-from-cdb.o src/conn-tools/s6-accessrules-fs-from-cdb.lo: src/conn-tools/s6-accessrules-fs-from-cdb.c src/conn-tools/s6-connlimit.o src/conn-tools/s6-connlimit.lo: src/conn-tools/s6-connlimit.c -src/conn-tools/s6-fdholderd.o src/conn-tools/s6-fdholderd.lo: src/conn-tools/s6-fdholderd.c src/include/s6/accessrules.h src/include/s6/s6-fdholder.h src/include/s6/s6-supervise.h +src/conn-tools/s6-fdholderd.o src/conn-tools/s6-fdholderd.lo: src/conn-tools/s6-fdholderd.c src/include/s6/accessrules.h src/include/s6/s6-fdholder.h src/conn-tools/s6-ioconnect.o src/conn-tools/s6-ioconnect.lo: src/conn-tools/s6-ioconnect.c src/conn-tools/s6-ipcclient.o src/conn-tools/s6-ipcclient.lo: src/conn-tools/s6-ipcclient.c src/conn-tools/s6-ipcserver-access.o src/conn-tools/s6-ipcserver-access.lo: src/conn-tools/s6-ipcserver-access.c src/include/s6/accessrules.h @@ -23,7 +23,6 @@ src/daemontools-extras/s6-envdir.o src/daemontools-extras/s6-envdir.lo: src/daem src/daemontools-extras/s6-envuidgid.o src/daemontools-extras/s6-envuidgid.lo: src/daemontools-extras/s6-envuidgid.c src/daemontools-extras/s6-fghack.o src/daemontools-extras/s6-fghack.lo: src/daemontools-extras/s6-fghack.c src/daemontools-extras/s6-log.o src/daemontools-extras/s6-log.lo: src/daemontools-extras/s6-log.c -src/daemontools-extras/s6-notifywhenup.o src/daemontools-extras/s6-notifywhenup.lo: src/daemontools-extras/s6-notifywhenup.c src/include/s6/ftrigw.h src/include/s6/s6-supervise.h src/daemontools-extras/s6-setlock.o src/daemontools-extras/s6-setlock.lo: src/daemontools-extras/s6-setlock.c src/include/s6/config.h src/daemontools-extras/s6-setsid.o src/daemontools-extras/s6-setsid.lo: src/daemontools-extras/s6-setsid.c src/daemontools-extras/s6-setuidgid.o src/daemontools-extras/s6-setuidgid.lo: src/daemontools-extras/s6-setuidgid.c src/include/s6/config.h @@ -95,6 +94,7 @@ src/pipe-tools/s6-ftrig-listen1.o src/pipe-tools/s6-ftrig-listen1.lo: src/pipe-t src/pipe-tools/s6-ftrig-notify.o src/pipe-tools/s6-ftrig-notify.lo: src/pipe-tools/s6-ftrig-notify.c src/include/s6/ftrigw.h src/pipe-tools/s6-ftrig-wait.o src/pipe-tools/s6-ftrig-wait.lo: src/pipe-tools/s6-ftrig-wait.c src/include/s6/ftrigr.h src/pipe-tools/s6-mkfifodir.o src/pipe-tools/s6-mkfifodir.lo: src/pipe-tools/s6-mkfifodir.c src/include/s6/ftrigw.h +src/supervision/s6-notifywhenup.o src/supervision/s6-notifywhenup.lo: src/supervision/s6-notifywhenup.c src/include/s6/ftrigw.h src/include/s6/s6-supervise.h src/supervision/s6-supervise.o src/supervision/s6-supervise.lo: src/supervision/s6-supervise.c src/include/s6/ftrigw.h src/include/s6/s6-supervise.h src/supervision/s6-svc.o src/supervision/s6-svc.lo: src/supervision/s6-svc.c src/include/s6/config.h src/include/s6/s6-supervise.h src/supervision/s6-svlisten.o src/supervision/s6-svlisten.lo: src/supervision/s6-svlisten.c src/include/s6/ftrigr.h src/include/s6/s6-supervise.h @@ -139,8 +139,6 @@ s6-fghack: private EXTRA_LIBS := s6-fghack: src/daemontools-extras/s6-fghack.o -lskarnet s6-log: private EXTRA_LIBS := ${TAINNOW_LIB} s6-log: src/daemontools-extras/s6-log.o -lskarnet -s6-notifywhenup: private EXTRA_LIBS := ${TAINNOW_LIB} -s6-notifywhenup: src/daemontools-extras/s6-notifywhenup.o ${LIBS6} -lskarnet s6-setlock: private EXTRA_LIBS := ${TAINNOW_LIB} s6-setlock: src/daemontools-extras/s6-setlock.o -lskarnet s6-setsid: private EXTRA_LIBS := @@ -175,6 +173,8 @@ s6-ftrig-wait: private EXTRA_LIBS := ${SOCKET_LIB} ${TAINNOW_LIB} s6-ftrig-wait: src/pipe-tools/s6-ftrig-wait.o ${LIBS6} -lskarnet s6-mkfifodir: private EXTRA_LIBS := s6-mkfifodir: src/pipe-tools/s6-mkfifodir.o ${LIBS6} -lskarnet +s6-notifywhenup: private EXTRA_LIBS := ${TAINNOW_LIB} +s6-notifywhenup: src/supervision/s6-notifywhenup.o ${LIBS6} -lskarnet s6-supervise: private EXTRA_LIBS := ${TAINNOW_LIB} s6-supervise: src/supervision/s6-supervise.o ${LIBS6} -lskarnet s6-svc: private EXTRA_LIBS := diff --git a/src/include/s6/s6-fdholder.h b/src/include/s6/s6-fdholder.h index 0285a21..7907607 100644 --- a/src/include/s6/s6-fdholder.h +++ b/src/include/s6/s6-fdholder.h @@ -10,6 +10,7 @@ #include <skalibs/unixconnection.h> #define S6_FDHOLDER_ID_SIZE 255 +#define S6_FDHOLDER_MAX 16 typedef struct s6_fdholder_s s6_fdholder_t, *s6_fdholder_t_ref ; struct s6_fdholder_s diff --git a/src/libs6/s6_fdholder_store_async.c b/src/libs6/s6_fdholder_store_async.c index dfaab05..2f783b1 100644 --- a/src/libs6/s6_fdholder_store_async.c +++ b/src/libs6/s6_fdholder_store_async.c @@ -14,7 +14,7 @@ int s6_fdholder_store_async (s6_fdholder_t *a, int fd, char const *id, tain_t co siovec_t v[2] = { { .s = pack, .len = 2 + TAIN_PACK }, { .s = id, .len = idlen + 1 } } ; unixmessage_v_t m = { .v = v, .vlen = 2, .fds = &fd, .nfds = 1 } ; if (idlen > S6_FDHOLDER_ID_SIZE) return (errno = ENAMETOOLONG, 0) ; - pack[1] = (unsigned char)idlen ; - tain_pack(pack + 2, limit) ; + tain_pack(pack + 1, limit) ; + pack[1+TAIN_PACK] = (unsigned char)idlen ; return unixmessage_putv(&a->connection.out, &m) ; } diff --git a/src/daemontools-extras/deps-exe/s6-notifywhenup b/src/supervision/deps-exe/s6-notifywhenup index 077e863..077e863 100644 --- a/src/daemontools-extras/deps-exe/s6-notifywhenup +++ b/src/supervision/deps-exe/s6-notifywhenup diff --git a/src/daemontools-extras/s6-notifywhenup.c b/src/supervision/s6-notifywhenup.c index e1c02b7..98f0401 100644 --- a/src/daemontools-extras/s6-notifywhenup.c +++ b/src/supervision/s6-notifywhenup.c @@ -21,6 +21,7 @@ static int run_child (int fd, char const *fifodir, unsigned int timeout) char dummy[4096] ; iopause_fd x = { .fd = fd, .events = IOPAUSE_READ } ; tain_t deadline ; + char pack[TAIN_PACK] ; if (!tain_now_g()) strerr_diefu1sys(111, "tain_now") ; if (timeout) tain_from_millisecs(&deadline, timeout) ; else deadline = tain_infinite_relative ; @@ -38,9 +39,9 @@ static int run_child (int fd, char const *fifodir, unsigned int timeout) if (byte_chr(dummy, r, '\n') < r) break ; } close(fd) ; - fd = open_create(S6_SUPERVISE_READY_FILENAME) ; - if (fd < 0) strerr_warnwu1sys("touch " S6_SUPERVISE_READY_FILENAME) ; - else close(fd) ; + tain_pack(pack, &STAMP) ; + if (!openwritenclose_suffix(S6_SUPERVISE_READY_FILENAME, pack, TAIN_PACK, ".new")) + strerr_warnwu1sys("open " S6_SUPERVISE_READY_FILENAME " for writing") ; ftrigw_notify(fifodir, 'U') ; return 0 ; } diff --git a/src/supervision/s6-svstat.c b/src/supervision/s6-svstat.c index 4f95a0c..de8fe0d 100644 --- a/src/supervision/s6-svstat.c +++ b/src/supervision/s6-svstat.c @@ -23,6 +23,7 @@ int main (int argc, char const *const *argv) s6_svstatus_t status ; int flagnum = 0 ; int isup, normallyup ; + tain_t readytime = TAIN_ZERO ; char fmt[UINT_FMT] ; PROG = "s6-svstat" ; { @@ -44,22 +45,32 @@ int main (int argc, char const *const *argv) if (!s6_svstatus_read(*argv, &status)) strerr_diefu2sys(111, "read status for ", *argv) ; + tain_now_g() ; + if (tain_future(&status.stamp)) tain_copynow(&status.stamp) ; + { + char pack[TAIN_PACK] ; struct stat st ; unsigned int dirlen = str_len(*argv) ; - char fn[dirlen + 6] ; + char fn[dirlen + sizeof(S6_SUPERVISE_READY_FILENAME) + 1] ; byte_copy(fn, dirlen, *argv) ; byte_copy(fn + dirlen, 6, "/down") ; if (stat(fn, &st) == -1) if (errno != ENOENT) strerr_diefu2sys(111, "stat ", fn) ; else normallyup = 1 ; else normallyup = 0 ; + byte_copy(fn + dirlen, sizeof(S6_SUPERVISE_READY_FILENAME) + 1, "/" S6_SUPERVISE_READY_FILENAME) ; + if (openreadnclose(fn, pack, TAIN_PACK) < TAIN_PACK) + { + if (errno != ENOENT) strerr_warnwu2sys("read ", fn) ; + } + else + { + tain_unpack(pack, &readytime) ; + if (tain_future(&readytime)) tain_copynow(&readytime) ; + } } - tain_now_g() ; - if (tain_future(&status.stamp)) tain_copynow(&status.stamp) ; - tain_sub(&status.stamp, &STAMP, &status.stamp) ; - isup = status.pid && !status.flagfinishing ; if (isup) { @@ -89,8 +100,9 @@ int main (int argc, char const *const *argv) buffer_putnoflush(buffer_1small, ") ", 2) ; } + tain_sub(&status.stamp, &STAMP, &status.stamp) ; buffer_putnoflush(buffer_1small, fmt, uint64_fmt(fmt, status.stamp.sec.x)) ; - buffer_putnoflush(buffer_1small," seconds", 8) ; + buffer_putnoflush(buffer_1small, " seconds", 8) ; if (isup && !normallyup) buffer_putnoflush(buffer_1small, ", normally down", 15) ; @@ -103,6 +115,13 @@ int main (int argc, char const *const *argv) if (isup && (status.flagwant == 'd')) buffer_putnoflush(buffer_1small, ", want down", 12) ; + if (readytime.sec.x) + { + tain_sub(&readytime, &STAMP, &readytime) ; + buffer_putnoflush(buffer_1small, ", ready ", 8) ; + buffer_putnoflush(buffer_1small, fmt, uint64_fmt(fmt, readytime.sec.x)) ; + buffer_putnoflush(buffer_1small, " seconds", 8) ; + } if (buffer_putflush(buffer_1small, "\n", 1) < 0) strerr_diefu1sys(111, "write to stdout") ; return 0 ; |