diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2018-07-21 11:31:45 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2018-07-21 11:31:45 +0000 |
commit | c8a41df9c5b16dce89ae008a0187c6d606013b61 (patch) | |
tree | 1b065ab6cc74ec4522b51b30b13b9cdb25153b7d /src | |
parent | 1626bf78dd47a42ce37e984025a434a666fc5bbf (diff) | |
download | s6-rc-c8a41df9c5b16dce89ae008a0187c6d606013b61.tar.xz |
Adapt to skalibs-2.7.0.0
Diffstat (limited to 'src')
-rw-r--r-- | src/libs6rc/s6rc_servicedir_block.c | 6 | ||||
-rw-r--r-- | src/libs6rc/s6rc_servicedir_manage.c | 27 | ||||
-rw-r--r-- | src/libs6rc/s6rc_servicedir_unsupervise.c | 6 | ||||
-rw-r--r-- | src/s6-rc/s6-rc-bundle.c | 5 |
4 files changed, 17 insertions, 27 deletions
diff --git a/src/libs6rc/s6rc_servicedir_block.c b/src/libs6rc/s6rc_servicedir_block.c index a7e2b12..bfa6440 100644 --- a/src/libs6rc/s6rc_servicedir_block.c +++ b/src/libs6rc/s6rc_servicedir_block.c @@ -1,8 +1,8 @@ /* ISC license. */ #include <string.h> -#include <errno.h> #include <unistd.h> +#include <skalibs/posixplz.h> #include <skalibs/djbunix.h> #include <s6/s6-supervise.h> #include <s6-rc/s6rc-servicedir.h> @@ -18,9 +18,7 @@ int s6rc_servicedir_block (char const *dir) if (!touch(fn)) return -1 ; if (s6_svc_writectl(dir, S6_SUPERVISE_CTLDIR, "O", 1) < 0) { - int e = errno ; - unlink(fn) ; - errno = e ; + unlink_void(fn) ; return -1 ; } return status.flagwantup ; diff --git a/src/libs6rc/s6rc_servicedir_manage.c b/src/libs6rc/s6rc_servicedir_manage.c index 940582c..5449f35 100644 --- a/src/libs6rc/s6rc_servicedir_manage.c +++ b/src/libs6rc/s6rc_servicedir_manage.c @@ -31,8 +31,8 @@ int s6rc_servicedir_manage (char const *live, char const *prefix, tain_t const * gid_t gid = getgid() ; size_t livelen = strlen(live) ; size_t prefixlen = strlen(prefix) ; + int fdlock ; int ok = 1 ; - int e = 0 ; DIR *dir ; char dirfn[livelen + 13] ; if (!ftrigr_startf(&a, deadline, stamp)) return 0 ; @@ -49,7 +49,6 @@ int s6rc_servicedir_manage (char const *live, char const *prefix, tain_t const * if (d->d_name[0] == '.') continue ; { size_t len = strlen(d->d_name) ; - int fdlock ; int r ; uint16_t id ; char srcfn[livelen + 20 + len] ; @@ -60,15 +59,15 @@ int s6rc_servicedir_manage (char const *live, char const *prefix, tain_t const * fdlock = s6_svc_lock_take(srcfn) ; if (fdlock < 0) goto err ; r = s6_svc_ok(srcfn) ; - if (r < 0) goto errinloop ; + if (r < 0) goto erru ; if (!r) { memcpy(srcfn + livelen + 13 + len, "/down", 6) ; - if (!touch(srcfn)) goto errinloop ; + if (!touch(srcfn)) goto erru ; memcpy(srcfn + livelen + 14 + len, "event", 6) ; - if (!ftrigw_fifodir_make(srcfn, gid, 0)) goto errinloop ; + if (!ftrigw_fifodir_make(srcfn, gid, 0)) goto erru ; id = ftrigr_subscribe(&a, srcfn, "s", 0, deadline, stamp) ; - if (!id) goto errinloop ; + if (!id) goto erru ; s6_svc_lock_release(fdlock) ; if (!genalloc_append(uint16_t, &ids, &id)) goto err ; srcfn[livelen + 13 + len] = 0 ; @@ -86,16 +85,10 @@ int s6rc_servicedir_manage (char const *live, char const *prefix, tain_t const * { if (!stralloc_catb(&newnames, d->d_name, len + 1)) { - e = errno ; s6rc_servicedir_unsupervise(live, prefix, d->d_name, 0) ; - goto errn ; + goto err ; } } - continue ; - errinloop: - e = errno ; - s6_svc_lock_release(fdlock) ; - goto errn ; } } if (errno) goto err ; @@ -117,18 +110,14 @@ int s6rc_servicedir_manage (char const *live, char const *prefix, tain_t const * stralloc_free(&newnames) ; return ok ; + erru: + s6_svc_lock_release(fdlock) ; err: - e = errno ; - errn: dir_close(dir) ; - goto closederrn ; closederr: - e = errno ; - closederrn: ftrigr_end(&a) ; genalloc_free(uint16_t, &ids) ; rollback(live, prefix, newnames.s, newnames.len) ; stralloc_free(&newnames) ; - errno = e ; return 0 ; } diff --git a/src/libs6rc/s6rc_servicedir_unsupervise.c b/src/libs6rc/s6rc_servicedir_unsupervise.c index 5db127b..2d15a70 100644 --- a/src/libs6rc/s6rc_servicedir_unsupervise.c +++ b/src/libs6rc/s6rc_servicedir_unsupervise.c @@ -1,7 +1,9 @@ /* ISC license. */ +#include <errno.h> #include <string.h> #include <unistd.h> +#include <skalibs/posixplz.h> #include <s6/s6-supervise.h> #include <s6-rc/s6rc-servicedir.h> @@ -15,11 +17,13 @@ void s6rc_servicedir_unsupervise (char const *live, char const *prefix, char con memcpy(fn + livelen, "/scandir/", 9) ; memcpy(fn + livelen + 9, prefix, prefixlen) ; memcpy(fn + livelen + 9 + prefixlen, name, namelen + 1) ; - unlink(fn) ; + unlink_void(fn) ; if (!keepsupervisor) { + int e = errno ; memcpy(fn + livelen + 1, "servicedirs/", 12) ; memcpy(fn + livelen + 13, name, namelen + 1) ; s6_svc_writectl(fn, S6_SUPERVISE_CTLDIR, "x", 1) ; + errno = e ; } } diff --git a/src/s6-rc/s6-rc-bundle.c b/src/s6-rc/s6-rc-bundle.c index f54ea7e..59d5dfb 100644 --- a/src/s6-rc/s6-rc-bundle.c +++ b/src/s6-rc/s6-rc-bundle.c @@ -5,6 +5,7 @@ #include <unistd.h> #include <errno.h> #include <stdio.h> +#include <skalibs/posixplz.h> #include <skalibs/uint32.h> #include <skalibs/buffer.h> #include <skalibs/strerr2.h> @@ -24,12 +25,10 @@ static void cleanup (char const *compiled) { size_t len = strlen(compiled) ; - int e = errno ; char fn[len + sizeof("/resolve.cdb.new")] ; memcpy(fn, compiled, len) ; memcpy(fn + len, "/resolve.cdb.new", sizeof("/resolve.cdb.new")) ; - unlink(fn) ; - errno = e ; + unlink_void(fn) ; } |