diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2015-09-02 15:35:19 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2015-09-02 15:35:19 +0000 |
commit | da164d5a27f61e3f935e3b223849fabbd717fc30 (patch) | |
tree | 12eecd20604e02ee22510c85480762b770b3514e | |
parent | 858dfd34bca20ea49d41f2f0249554d9cb225069 (diff) | |
download | s6-rc-da164d5a27f61e3f935e3b223849fabbd717fc30.tar.xz |
Fix the regression in s6-rc-init; progress on s6-rc-update
-rw-r--r-- | doc/s6-rc-compile.html | 7 | ||||
-rw-r--r-- | package/deps.mak | 5 | ||||
-rw-r--r-- | src/include/s6-rc/s6rc-servicedir.h | 7 | ||||
-rw-r--r-- | src/libs6rc/s6rc_servicedir_manage.c | 219 | ||||
-rw-r--r-- | src/s6-rc/s6-rc-init.c | 163 | ||||
-rw-r--r-- | src/s6-rc/s6-rc-update.c | 11 |
6 files changed, 122 insertions, 290 deletions
diff --git a/doc/s6-rc-compile.html b/doc/s6-rc-compile.html index 6e539e4..0c1afc1 100644 --- a/doc/s6-rc-compile.html +++ b/doc/s6-rc-compile.html @@ -347,11 +347,10 @@ detect and reject cycles as well as collisions. </p> <p> - The pipe linking a producer and a consumer is created by an automatically -generated oneshot service that both the producer and consumer depend on, -and stored in a + The pipe linking a producer and a consumer is created and stored at run-time in a <a href="http://skarnet.org/software/s6/s6-fdholder-daemon.html">s6-fdholder-daemon</a> -instance created by an automatically generated longrun service. +instance managed by an automatically generated longrun service named +<tt>s6rc-fdholder</tt>. </p> <h2> A complete example </h2> diff --git a/package/deps.mak b/package/deps.mak index 7d388fb..d97c2c5 100644 --- a/package/deps.mak +++ b/package/deps.mak @@ -18,6 +18,7 @@ src/libs6rc/s6rc_servicedir_block.o src/libs6rc/s6rc_servicedir_block.lo: src/li src/libs6rc/s6rc_servicedir_copy_offline.o src/libs6rc/s6rc_servicedir_copy_offline.lo: src/libs6rc/s6rc_servicedir_copy_offline.c src/include/s6-rc/s6rc-servicedir.h src/libs6rc/s6rc-servicedir-internal.h src/libs6rc/s6rc_servicedir_copy_online.o src/libs6rc/s6rc_servicedir_copy_online.lo: src/libs6rc/s6rc_servicedir_copy_online.c src/include/s6-rc/s6rc-servicedir.h src/include/s6-rc/s6rc-utils.h src/libs6rc/s6rc-servicedir-internal.h src/libs6rc/s6rc_servicedir_internal.o src/libs6rc/s6rc_servicedir_internal.lo: src/libs6rc/s6rc_servicedir_internal.c src/include/s6-rc/s6rc-utils.h src/libs6rc/s6rc-servicedir-internal.h +src/libs6rc/s6rc_servicedir_manage.o src/libs6rc/s6rc_servicedir_manage.lo: src/libs6rc/s6rc_servicedir_manage.c src/include/s6-rc/s6rc-servicedir.h src/libs6rc/s6rc_servicedir_unblock.o src/libs6rc/s6rc_servicedir_unblock.lo: src/libs6rc/s6rc_servicedir_unblock.c src/include/s6-rc/s6rc-servicedir.h src/s6-rc/s6-rc-bundle.o src/s6-rc/s6-rc-bundle.lo: src/s6-rc/s6-rc-bundle.c src/include/s6-rc/config.h src/include/s6-rc/s6rc.h src/s6-rc/s6-rc-compile.o src/s6-rc/s6-rc-compile.lo: src/s6-rc/s6-rc-compile.c src/include/s6-rc/config.h src/include/s6-rc/s6rc.h @@ -28,9 +29,9 @@ src/s6-rc/s6-rc-init.o src/s6-rc/s6-rc-init.lo: src/s6-rc/s6-rc-init.c src/inclu src/s6-rc/s6-rc-update.o src/s6-rc/s6-rc-update.lo: src/s6-rc/s6-rc-update.c src/include/s6-rc/config.h src/include/s6-rc/s6rc.h src/s6-rc/s6-rc.o src/s6-rc/s6-rc.lo: src/s6-rc/s6-rc.c src/include/s6-rc/config.h src/include/s6-rc/s6rc.h -libs6rc.a.xyzzy: src/libs6rc/s6rc_db_check_depcycles.o src/libs6rc/s6rc_db_check_pipelines.o src/libs6rc/s6rc_db_check_revdeps.o src/libs6rc/s6rc_db_read.o src/libs6rc/s6rc_db_read_sizes.o src/libs6rc/s6rc_db_read_uint32.o src/libs6rc/s6rc_graph_closure.o src/libs6rc/s6rc_lock.o src/libs6rc/s6rc_read_uint.o src/libs6rc/s6rc_sanitize_dir.o src/libs6rc/s6rc_servicedir_internal.o src/libs6rc/s6rc_servicedir_block.o src/libs6rc/s6rc_servicedir_unblock.o src/libs6rc/s6rc_servicedir_copy_offline.o src/libs6rc/s6rc_servicedir_copy_online.o +libs6rc.a.xyzzy: src/libs6rc/s6rc_db_check_depcycles.o src/libs6rc/s6rc_db_check_pipelines.o src/libs6rc/s6rc_db_check_revdeps.o src/libs6rc/s6rc_db_read.o src/libs6rc/s6rc_db_read_sizes.o src/libs6rc/s6rc_db_read_uint32.o src/libs6rc/s6rc_graph_closure.o src/libs6rc/s6rc_lock.o src/libs6rc/s6rc_read_uint.o src/libs6rc/s6rc_sanitize_dir.o src/libs6rc/s6rc_servicedir_internal.o src/libs6rc/s6rc_servicedir_block.o src/libs6rc/s6rc_servicedir_unblock.o src/libs6rc/s6rc_servicedir_copy_offline.o src/libs6rc/s6rc_servicedir_copy_online.o src/libs6rc/s6rc_servicedir_manage.o libs6rc.so.xyzzy: private EXTRA_LIBS := -ls6 -lskarnet -libs6rc.so.xyzzy: src/libs6rc/s6rc_db_check_depcycles.lo src/libs6rc/s6rc_db_check_pipelines.lo src/libs6rc/s6rc_db_check_revdeps.lo src/libs6rc/s6rc_db_read.lo src/libs6rc/s6rc_db_read_sizes.lo src/libs6rc/s6rc_db_read_uint32.lo src/libs6rc/s6rc_graph_closure.lo src/libs6rc/s6rc_lock.lo src/libs6rc/s6rc_read_uint.lo src/libs6rc/s6rc_sanitize_dir.lo src/libs6rc/s6rc_servicedir_internal.lo src/libs6rc/s6rc_servicedir_block.lo src/libs6rc/s6rc_servicedir_unblock.lo src/libs6rc/s6rc_servicedir_copy_offline.lo src/libs6rc/s6rc_servicedir_copy_online.lo +libs6rc.so.xyzzy: src/libs6rc/s6rc_db_check_depcycles.lo src/libs6rc/s6rc_db_check_pipelines.lo src/libs6rc/s6rc_db_check_revdeps.lo src/libs6rc/s6rc_db_read.lo src/libs6rc/s6rc_db_read_sizes.lo src/libs6rc/s6rc_db_read_uint32.lo src/libs6rc/s6rc_graph_closure.lo src/libs6rc/s6rc_lock.lo src/libs6rc/s6rc_read_uint.lo src/libs6rc/s6rc_sanitize_dir.lo src/libs6rc/s6rc_servicedir_internal.lo src/libs6rc/s6rc_servicedir_block.lo src/libs6rc/s6rc_servicedir_unblock.lo src/libs6rc/s6rc_servicedir_copy_offline.lo src/libs6rc/s6rc_servicedir_copy_online.lo src/libs6rc/s6rc_servicedir_manage.lo s6-rc: private EXTRA_LIBS := ${TAINNOW_LIB} s6-rc: src/s6-rc/s6-rc.o ${LIBS6RC} -lskarnet s6-rc-bundle: private EXTRA_LIBS := diff --git a/src/include/s6-rc/s6rc-servicedir.h b/src/include/s6-rc/s6rc-servicedir.h index e9475bd..93baef7 100644 --- a/src/include/s6-rc/s6rc-servicedir.h +++ b/src/include/s6-rc/s6rc-servicedir.h @@ -3,12 +3,15 @@ #ifndef S6RC_SERVICEDIR_H #define S6RC_SERVICEDIR_H +#include <skalibs/tai.h> + extern int s6rc_servicedir_block (char const *) ; extern int s6rc_servicedir_unblock (char const *, int) ; extern int s6rc_servicedir_copy_offline (char const *, char const *) ; extern int s6rc_servicedir_copy_online (char const *, char const *) ; #define s6rc_servicedir_copy(src, dst, h) ((h) ? s6rc_servicedir_copy_online(src, dst) : s6rc_servicedir_copy_offline(src, dst)) -extern int s6rc_servicedir_supervise () ; -extern void s6rc_servicedir_unsupervise (char const *, char const *const *, unsigned int) ; + +extern int s6rc_servicedir_manage (char const *, tain_t const *, tain_t *) ; +#define s6rc_servicedir_manage_g(live, deadline) s6rc_servicedir_manage(live, (deadline), &STAMP) #endif diff --git a/src/libs6rc/s6rc_servicedir_manage.c b/src/libs6rc/s6rc_servicedir_manage.c index 3c883be..bad4f4b 100644 --- a/src/libs6rc/s6rc_servicedir_manage.c +++ b/src/libs6rc/s6rc_servicedir_manage.c @@ -1,152 +1,91 @@ /* ISC license. */ +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +#include <errno.h> +#include <skalibs/uint16.h> +#include <skalibs/bytestr.h> #include <skalibs/tai.h> +#include <skalibs/direntry.h> +#include <skalibs/djbunix.h> +#include <skalibs/genalloc.h> +#include <s6/s6-supervise.h> +#include <s6/ftrigr.h> +#include <s6/ftrigw.h> #include <s6-rc/s6rc-servicedir.h> - -static int s6rc_servicedir_manage (char const *live, unsigned char const *state, unsigned int nlong, tain_t const *deadline) +int s6rc_servicedir_manage (char const *live, tain_t const *deadline, tain_t *stamp) { -#if 0 + ftrigr_t a = FTRIGR_ZERO ; + genalloc ids = GENALLOC_ZERO ; /* uint16 */ + gid_t gid = getgid() ; unsigned int livelen = str_len(live) ; - char - byte_copy(lfn + llen + 1, 12, "servicedirs") ; - byte_copy(cfn, llen + 1, lfn) ; - byte_copy(cfn + llen + 1, 21, "compiled/servicedirs") ; - if (!hiercopy(cfn, lfn)) - { - cleanup() ; - strerr_diefu4sys(111, "recursively copy ", cfn, " to ", lfn) ; - } - - tain_now_g() ; - tain_add_g(&deadline, &tto) ; - dir = opendir(lfn) ; - if (!dir) + int ok = 1 ; + int e ; + DIR *dir ; + char dirfn[livelen + 13] ; + if (!ftrigr_startf(&a, deadline, stamp)) return 0 ; + byte_copy(dirfn, livelen, live) ; + byte_copy(dirfn + livelen, 13, "/servicedirs") ; + dir = opendir(dirfn) ; + if (!dir) goto closederr ; + for (;;) + { + direntry *d ; + errno = 0 ; + d = readdir(dir) ; + if (!d) break ; + if (d->d_name[0] == '.') continue ; { - cleanup() ; - strerr_diefu2sys(111, "opendir ", lfn) ; + unsigned int len = str_len(d->d_name) ; + uint16 id ; + char srcfn[livelen + 20 + len] ; + char dstfn[livelen + 10 + len] ; + register int r ; + byte_copy(srcfn, livelen + 12, dirfn) ; + srcfn[livelen + 12] = '/' ; + byte_copy(srcfn + livelen + 13, len + 1, d->d_name) ; + r = s6_svc_ok(srcfn) ; + if (r < 0) { e = errno ; goto err ; } + if (r) continue ; + byte_copy(srcfn + livelen + 13 + len, 6, "/down") ; + if (!touch(srcfn)) { e = errno ; goto err ; } + byte_copy(srcfn + livelen + 14 + len, 6, "event") ; + if (!ftrigw_fifodir_make(srcfn, gid, 0)) { e = errno ; goto err ; } + id = ftrigr_subscribe(&a, srcfn, "s", 0, deadline, stamp) ; + if (!id) { e = errno ; goto err ; } + if (!genalloc_append(uint16, &ids, &id)) { e = errno ; goto err ; } + srcfn[livelen + 13 + len] = 0 ; + byte_copy(dstfn, livelen, live) ; + byte_copy(dstfn + livelen, 9, "/scandir/") ; + byte_copy(dstfn + livelen + 9, len + 1, d->d_name) ; + if (symlink(srcfn, dstfn) < 0) { e = errno ; goto err ; } } - for (;;) - { - unsigned int thislen ; - direntry *d ; - errno = 0 ; - d = readdir(dir) ; - if (!d) break ; - if (d->d_name[0] == '.') continue ; - thislen = str_len(d->d_name) ; - if (thislen > maxlen) maxlen = thislen ; - ndirs++ ; - } - if (errno) - { - int e = errno ; - dir_close(dir) ; - errno = e ; - cleanup() ; - strerr_diefu2sys(111, "readdir ", lfn) ; - } - if (ndirs) - { - ftrigr_t a = FTRIGR_ZERO ; - gid_t gid = getgid() ; - unsigned int i = 0 ; - int r ; - uint16 ids[ndirs] ; - char srcfn[llen + 23 + maxlen] ; /* XXX: unsafe if dir is writable by non-root */ - char dstfn[llen + 9 + sizeof(S6_SVSCAN_CTLDIR "/control") + maxlen] ; - rewinddir(dir) ; - byte_copy(srcfn, llen + 12, lfn) ; - srcfn[llen + 12] = '/' ; - byte_copy(dstfn, llen, satmp.s) ; - byte_copy(dstfn + llen, 8, "/scandir") ; - dstfn[llen + 8] = '/' ; - if (!ftrigr_startf_g(&a, &deadline)) - { - int e = errno ; - dir_close(dir) ; - errno = e ; - cleanup() ; - strerr_diefu1sys(111, "start event listener process") ; - } - for (;;) - { - unsigned int thislen ; - direntry *d ; - errno = 0 ; - d = readdir(dir) ; - if (!d) break ; - if (d->d_name[0] == '.') continue ; - thislen = str_len(d->d_name) ; - byte_copy(srcfn + llen + 13, thislen, d->d_name) ; - byte_copy(srcfn + llen + 13 + thislen, 6, "/down") ; - if (!touch(srcfn)) - { - cleanup() ; - strerr_diefu2sys(111, "touch ", srcfn) ; - } - byte_copy(srcfn + llen + 14 + thislen, 9, "log/down") ; - if (!touch(srcfn)) - { - cleanup() ; - strerr_diefu2sys(111, "touch ", srcfn) ; - } - byte_copy(srcfn + llen + 14 + thislen, 6, "event") ; - if (!ftrigw_fifodir_make(srcfn, gid, 0)) - { - cleanup() ; - strerr_diefu2sys(111, "make fifodir ", srcfn) ; - } - ids[i] = ftrigr_subscribe_g(&a, srcfn, "s", 0, &deadline) ; - if (!ids[i]) - { - int e = errno ; - dir_close(dir) ; - errno = e ; - cleanup() ; - strerr_diefu2sys(111, "subscribe to ", srcfn) ; - } - srcfn[llen + 13 + thislen] = 0 ; - byte_copy(dstfn + llen + 9, thislen + 1, d->d_name) ; - if (symlink(srcfn, dstfn) < 0) - { - int e = errno ; - dir_close(dir) ; - errno = e ; - cleanup() ; - strerr_diefu4sys(111, "symlink ", srcfn, " to ", dstfn) ; - } - i++ ; - } - if (errno) - { - int e = errno ; - dir_close(dir) ; - errno = e ; - cleanup() ; - strerr_diefu2sys(111, "readdir ", lfn) ; - } - dir_close(dir) ; - byte_copy(dstfn + llen + 9, sizeof(S6_SVSCAN_CTLDIR "/control"), S6_SVSCAN_CTLDIR "/control") ; - r = s6_svc_write(dstfn, "a", 1) ; - if (r < 0) - { - cleanup() ; - strerr_diefu2sys(111, "write to ", dstfn) ; - } - if (!r) strerr_warnw2x("s6-svscan not running on ", argv[0]) ; - else - { - if (ftrigr_wait_and_g(&a, ids, ndirs, &deadline) < 0) - { - cleanup() ; - strerr_diefu1sys(111, "wait for s6-supervise processes to come up") ; - } - } - ftrigr_end(&a) ; - } - else dir_close(dir) ; } -#endif + if (errno) { e = errno ; goto err ; } + dir_close(dir) ; + { + char scanfn[livelen + 9] ; + register int r ; + byte_copy(scanfn, livelen, live) ; + byte_copy(scanfn + livelen, 9, "/scandir") ; + r = s6_svc_writectl(scanfn, S6_SVSCAN_CTLDIR, "a", 1) ; + if (r < 0) { e = errno ; goto closederr ; } + if (!r) ok = 3 ; + else if (ftrigr_wait_and(&a, genalloc_s(uint16, &ids), genalloc_len(uint16, &ids), deadline, stamp) < 0) + { e = errno ; goto closederr ; } + } + + genalloc_free(uint16, &ids) ; + ftrigr_end(&a) ; + return ok ; + + err: + dir_close(dir) ; + closederr: + genalloc_free(uint16, &ids) ; + ftrigr_end(&a) ; + errno = e ; return 0 ; } diff --git a/src/s6-rc/s6-rc-init.c b/src/s6-rc/s6-rc-init.c index eec2a69..2337823 100644 --- a/src/s6-rc/s6-rc-init.c +++ b/src/s6-rc/s6-rc-init.c @@ -1,21 +1,15 @@ /* ISC license. */ -#include <sys/stat.h> #include <unistd.h> #include <errno.h> -#include <skalibs/uint16.h> #include <skalibs/uint.h> #include <skalibs/bytestr.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> #include <skalibs/stralloc.h> -#include <skalibs/direntry.h> #include <skalibs/tai.h> #include <skalibs/djbunix.h> #include <skalibs/skamisc.h> -#include <s6/s6-supervise.h> -#include <s6/ftrigw.h> -#include <s6/ftrigr.h> #include <s6-rc/config.h> #include <s6-rc/s6rc.h> @@ -30,7 +24,7 @@ static void cleanup (void) int e = errno ; satmp.s[llen] = 0 ; unlink(satmp.s) ; - satmp.s[llen] = '.' ; + satmp.s[llen] = ':' ; rm_rf_in_tmp(&satmp, 0) ; stralloc_free(&satmp) ; errno = e ; @@ -71,6 +65,9 @@ int main (int argc, char const *const *argv) if (argv[0][0] != '/') strerr_dief2x(100, "scandir", " must be an absolute path") ; + tain_now_g() ; + tain_add_g(&deadline, &tto) ; + if (!s6rc_sanitize_dir(&satmp, live, &dirlen)) dienomem() ; llen = satmp.len ; if (!stralloc_cats(&satmp, ":initial") || !stralloc_0(&satmp)) @@ -79,10 +76,8 @@ int main (int argc, char const *const *argv) { int fdlock ; int fdcompiled ; + int ok ; s6rc_db_t db ; - DIR *dir ; - unsigned int maxlen = 0 ; - unsigned int ndirs = 0 ; unsigned int n ; char lfn[llen + 13] ; char cfn[llen + 23] ; @@ -90,13 +85,16 @@ int main (int argc, char const *const *argv) /* Create the real dir, lock it, symlink */ + unlink(live) ; + rm_rf(satmp.s) ; if (mkdir(satmp.s, 0755) < 0) strerr_diefu2sys(111, "mkdir ", satmp.s) ; if (!s6rc_lock(satmp.s, 2, &fdlock, 0, 0, 0)) { cleanup() ; strerr_diefu2sys(111, "take lock on ", satmp.s) ; } - byte_copy(lfn, llen, live) ; lfn[llen] = 0 ; + byte_copy(lfn, llen, satmp.s) ; + lfn[llen] = 0 ; if (symlink(satmp.s + dirlen, lfn) < 0) { cleanup() ; @@ -104,7 +102,7 @@ int main (int argc, char const *const *argv) } - /* compiled */ + /* compiled */ fdcompiled = open_readb(compiled) ; if (fdcompiled < 0) @@ -112,7 +110,7 @@ int main (int argc, char const *const *argv) cleanup() ; strerr_diefu2sys(111, "open ", compiled) ; } - byte_copy(lfn + llen + 1, 9, "compiled") ; + byte_copy(lfn + llen, 10, "/compiled") ; if (symlink(compiled, lfn) < 0) { cleanup() ; @@ -120,7 +118,7 @@ int main (int argc, char const *const *argv) } - /* scandir */ + /* scandir */ byte_copy(lfn + llen + 1, 8, "scandir") ; if (symlink(argv[0], lfn) < 0) @@ -132,7 +130,6 @@ int main (int argc, char const *const *argv) /* state */ - byte_copy(lfn + llen + 1, 6, "state") ; { register int r = s6rc_db_read_sizes(fdcompiled, &db) ; @@ -167,134 +164,18 @@ int main (int argc, char const *const *argv) strerr_diefu4sys(111, "recursively copy ", cfn, " to ", lfn) ; } - tain_now_g() ; - tain_add_g(&deadline, &tto) ; - dir = opendir(lfn) ; - if (!dir) - { - cleanup() ; - strerr_diefu2sys(111, "opendir ", lfn) ; - } - for (;;) - { - unsigned int thislen ; - direntry *d ; - errno = 0 ; - d = readdir(dir) ; - if (!d) break ; - if (d->d_name[0] == '.') continue ; - thislen = str_len(d->d_name) ; - if (thislen > maxlen) maxlen = thislen ; - ndirs++ ; - } - if (errno) + + /* start the supervisors */ + + lfn[llen] = 0 ; + ok = s6rc_servicedir_manage_g(lfn, &deadline) ; + if (!ok) { - int e = errno ; - dir_close(dir) ; - errno = e ; cleanup() ; - strerr_diefu2sys(111, "readdir ", lfn) ; - } - if (ndirs) - { - ftrigr_t a = FTRIGR_ZERO ; - gid_t gid = getgid() ; - unsigned int i = 0 ; - int r ; - uint16 ids[ndirs] ; - char srcfn[llen + 23 + maxlen] ; /* XXX: unsafe if dir is writable by non-root */ - char dstfn[llen + 9 + sizeof(S6_SVSCAN_CTLDIR "/control") + maxlen] ; - rewinddir(dir) ; - byte_copy(srcfn, llen + 12, lfn) ; - srcfn[llen + 12] = '/' ; - byte_copy(dstfn, llen, satmp.s) ; - byte_copy(dstfn + llen, 8, "/scandir") ; - dstfn[llen + 8] = '/' ; - if (!ftrigr_startf_g(&a, &deadline)) - { - int e = errno ; - dir_close(dir) ; - errno = e ; - cleanup() ; - strerr_diefu1sys(111, "start event listener process") ; - } - for (;;) - { - unsigned int thislen ; - direntry *d ; - errno = 0 ; - d = readdir(dir) ; - if (!d) break ; - if (d->d_name[0] == '.') continue ; - thislen = str_len(d->d_name) ; - byte_copy(srcfn + llen + 13, thislen, d->d_name) ; - byte_copy(srcfn + llen + 13 + thislen, 6, "/down") ; - if (!touch(srcfn)) - { - cleanup() ; - strerr_diefu2sys(111, "touch ", srcfn) ; - } - byte_copy(srcfn + llen + 14 + thislen, 9, "log/down") ; - if (!touch(srcfn)) - { - cleanup() ; - strerr_diefu2sys(111, "touch ", srcfn) ; - } - byte_copy(srcfn + llen + 14 + thislen, 6, "event") ; - if (!ftrigw_fifodir_make(srcfn, gid, 0)) - { - cleanup() ; - strerr_diefu2sys(111, "make fifodir ", srcfn) ; - } - ids[i] = ftrigr_subscribe_g(&a, srcfn, "s", 0, &deadline) ; - if (!ids[i]) - { - int e = errno ; - dir_close(dir) ; - errno = e ; - cleanup() ; - strerr_diefu2sys(111, "subscribe to ", srcfn) ; - } - srcfn[llen + 13 + thislen] = 0 ; - byte_copy(dstfn + llen + 9, thislen + 1, d->d_name) ; - if (symlink(srcfn, dstfn) < 0) - { - int e = errno ; - dir_close(dir) ; - errno = e ; - cleanup() ; - strerr_diefu4sys(111, "symlink ", srcfn, " to ", dstfn) ; - } - i++ ; - } - if (errno) - { - int e = errno ; - dir_close(dir) ; - errno = e ; - cleanup() ; - strerr_diefu2sys(111, "readdir ", lfn) ; - } - dir_close(dir) ; - byte_copy(dstfn + llen + 9, sizeof(S6_SVSCAN_CTLDIR "/control"), S6_SVSCAN_CTLDIR "/control") ; - r = s6_svc_write(dstfn, "a", 1) ; - if (r < 0) - { - cleanup() ; - strerr_diefu2sys(111, "write to ", dstfn) ; - } - if (!r) strerr_warnw2x("s6-svscan not running on ", argv[0]) ; - else - { - if (ftrigr_wait_and_g(&a, ids, ndirs, &deadline) < 0) - { - cleanup() ; - strerr_diefu1sys(111, "wait for s6-supervise processes to come up") ; - } - } - ftrigr_end(&a) ; + strerr_diefu3sys(111, "supervise service directories in ", lfn, "/servicedirs") ; } - else dir_close(dir) ; - } + if (ok & 2) + strerr_warnw3x("s6-svscan not running on ", lfn, "/scandir") ; + } return 0 ; } diff --git a/src/s6-rc/s6-rc-update.c b/src/s6-rc/s6-rc-update.c index f179a50..796f738 100644 --- a/src/s6-rc/s6-rc-update.c +++ b/src/s6-rc/s6-rc-update.c @@ -373,6 +373,9 @@ static inline void make_new_livedir (unsigned char const *oldstate, s6rc_db_t co } } + if (verbosity >= 2) + strerr_warni1x("successfully switched to new database") ; + /* scandir cleanup, then old livedir cleanup */ sa->len = dirlen ; sa->s[sa->len++] = '/' ; @@ -529,7 +532,7 @@ int main (int argc, char const *const *argv, char const *const *envp) tain_t deadline ; int dryrun = 0 ; PROG = "s6-rc-update" ; - strerr_dief1x(100, "nope, not quite yet.") ; + strerr_dief1x(100, "almost there. Just a little more patience.") ; { unsigned int t = 0 ; subgetopt_t l = SUBGETOPT_ZERO ; @@ -692,12 +695,18 @@ int main (int argc, char const *const *argv, char const *const *envp) if (!dryrun) { + int r ; /* Update state and service directories */ if (verbosity >= 2) strerr_warni1x("updating state and service directories") ; + make_new_livedir (oldstate, &olddb, newstate, &newdb, argv[0], newlong, &sa) ; + r = s6rc_servicedir_manage_g(live, &deadline) ; + if (!r) strerr_diefu2sys(111, "manage new service directories in ", live) ; + if (r & 2) strerr_warnw3x("s6-svscan not running on ", live, "/scandir") ; + /* Adjust stored pipelines */ |