diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2020-01-03 15:03:52 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2020-01-03 15:03:52 +0000 |
commit | efe2eb4bbf383864ff2bb83fb0d10d98ce8fd1da (patch) | |
tree | 470b2e24bf61069b08e5e9c13bfdf4c00c14e97c | |
parent | 11b672b12e16fe47bebb00858f8abcd2a2005b8d (diff) | |
download | s6-rc-efe2eb4bbf383864ff2bb83fb0d10d98ce8fd1da.tar.xz |
Code cleanup
-rw-r--r-- | src/s6-rc/s6-rc-bundle.c | 5 | ||||
-rw-r--r-- | src/s6-rc/s6-rc-compile.c | 17 | ||||
-rw-r--r-- | src/s6-rc/s6-rc-db.c | 2 | ||||
-rw-r--r-- | src/s6-rc/s6-rc-format-upgrade.c | 2 | ||||
-rw-r--r-- | src/s6-rc/s6-rc-init.c | 2 | ||||
-rw-r--r-- | src/s6-rc/s6-rc-oneshot-run.c | 3 | ||||
-rw-r--r-- | src/s6-rc/s6-rc-update.c | 4 | ||||
-rw-r--r-- | src/s6-rc/s6-rc.c | 23 |
8 files changed, 38 insertions, 20 deletions
diff --git a/src/s6-rc/s6-rc-bundle.c b/src/s6-rc/s6-rc-bundle.c index 4a07804..3825e25 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> @@ -15,7 +16,9 @@ #include <skalibs/cdb.h> #include <skalibs/cdb_make.h> #include <skalibs/unix-transactional.h> + #include <execline/execline.h> + #include <s6-rc/config.h> #include <s6-rc/s6rc.h> @@ -32,7 +35,7 @@ static void cleanup (char const *compiled) } - /* switch to renameat when it's more portable */ + /* TODO: switch to renameat when it's more portable */ static inline int renameit (char const *compiled, char const *src, char const *dst) { diff --git a/src/s6-rc/s6-rc-compile.c b/src/s6-rc/s6-rc-compile.c index bdad01e..9ce6240 100644 --- a/src/s6-rc/s6-rc-compile.c +++ b/src/s6-rc/s6-rc-compile.c @@ -7,6 +7,7 @@ #include <unistd.h> #include <errno.h> #include <stdlib.h> /* qsort */ + #include <skalibs/types.h> #include <skalibs/bitarray.h> #include <skalibs/strerr2.h> @@ -21,9 +22,12 @@ #include <skalibs/skamisc.h> #include <skalibs/avltree.h> #include <skalibs/unix-transactional.h> + #include <execline/config.h> #include <execline/execline.h> + #include <s6/config.h> + #include <s6-rc/config.h> #include <s6-rc/s6rc.h> @@ -248,7 +252,7 @@ static unsigned int add_internal_longrun (before_t *be, char const *name) return pos ; } -static int uint_uniq (unsigned int const *list, unsigned int n, unsigned int pos) +static inline int uint_uniq (unsigned int const *list, unsigned int n, unsigned int pos) { while (n--) if (pos == list[n]) return 0 ; return 1 ; @@ -1075,12 +1079,6 @@ static inline void write_fdholder (char const *compiled, s6rc_db_t const *db, ch auto_rights(compiled, "servicedirs/" S6RC_FDHOLDER "/run", 0755) ; } -static inline void write_specials (char const *compiled, s6rc_db_t const *db, char const *fdhuser, int blocking) -{ - write_oneshot_runner(compiled, blocking) ; - write_fdholder(compiled, db, fdhuser) ; -} - static inline void write_resolve (char const *compiled, s6rc_db_t const *db, bundle_t const *bundles, unsigned int nbundles, uint32_t const *bdeps) { size_t clen = strlen(compiled) ; @@ -1311,7 +1309,7 @@ static inline void write_servicedirs (char const *compiled, s6rc_db_t const *db, } } -static inline int write_service (buffer *b, s6rc_service_t const *sv, int type) +static int write_service (buffer *b, s6rc_service_t const *sv, int type) { char pack[49] ; unsigned int m ; @@ -1423,7 +1421,8 @@ static inline void write_compiled ( write_resolve(compiled, db, bundles, nbundles, bdeps) ; stralloc_free(&data) ; write_db(compiled, db) ; - write_specials(compiled, db, fdhuser, blocking) ; + write_oneshot_runner(compiled, blocking) ; + write_fdholder(compiled, db, fdhuser) ; write_servicedirs(compiled, db, srcdirs) ; } diff --git a/src/s6-rc/s6-rc-db.c b/src/s6-rc/s6-rc-db.c index 37092a7..d29b148 100644 --- a/src/s6-rc/s6-rc-db.c +++ b/src/s6-rc/s6-rc-db.c @@ -3,6 +3,7 @@ #include <string.h> #include <stdint.h> #include <unistd.h> + #include <skalibs/uint32.h> #include <skalibs/sgetopt.h> #include <skalibs/buffer.h> @@ -10,6 +11,7 @@ #include <skalibs/djbunix.h> #include <skalibs/cdb.h> #include <skalibs/unix-transactional.h> + #include <s6-rc/config.h> #include <s6-rc/s6rc.h> diff --git a/src/s6-rc/s6-rc-format-upgrade.c b/src/s6-rc/s6-rc-format-upgrade.c index 15399b6..e2049de 100644 --- a/src/s6-rc/s6-rc-format-upgrade.c +++ b/src/s6-rc/s6-rc-format-upgrade.c @@ -1,11 +1,13 @@ /* ISC license. */ #include <string.h> + #include <skalibs/types.h> #include <skalibs/strerr2.h> #include <skalibs/sgetopt.h> #include <skalibs/tai.h> #include <skalibs/unix-transactional.h> + #include <s6-rc/config.h> #include <s6-rc/s6rc.h> diff --git a/src/s6-rc/s6-rc-init.c b/src/s6-rc/s6-rc-init.c index e3a1984..5551d6e 100644 --- a/src/s6-rc/s6-rc-init.c +++ b/src/s6-rc/s6-rc-init.c @@ -4,6 +4,7 @@ #include <unistd.h> #include <errno.h> #include <stdlib.h> + #include <skalibs/types.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> @@ -11,6 +12,7 @@ #include <skalibs/tai.h> #include <skalibs/djbunix.h> #include <skalibs/unix-transactional.h> + #include <s6-rc/config.h> #include <s6-rc/s6rc.h> diff --git a/src/s6-rc/s6-rc-oneshot-run.c b/src/s6-rc/s6-rc-oneshot-run.c index 835e89c..d80f704 100644 --- a/src/s6-rc/s6-rc-oneshot-run.c +++ b/src/s6-rc/s6-rc-oneshot-run.c @@ -4,10 +4,12 @@ #include <strings.h> #include <stdint.h> #include <unistd.h> + #include <skalibs/types.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> + #include <s6-rc/config.h> #include <s6-rc/s6rc.h> @@ -90,6 +92,7 @@ int main (int argc, char const *const *argv, char const *const *envp) if (r < 0) strerr_diefu3sys(111, "read ", compiled, "/db") ; if (!r) strerr_dief3x(4, "invalid service database in ", compiled, "/db") ; close(fdcompiled) ; + close(compiledlock) ; /* Run the script */ diff --git a/src/s6-rc/s6-rc-update.c b/src/s6-rc/s6-rc-update.c index 78ab0de..56cce96 100644 --- a/src/s6-rc/s6-rc-update.c +++ b/src/s6-rc/s6-rc-update.c @@ -9,6 +9,7 @@ #include <errno.h> #include <stdio.h> #include <stdlib.h> + #include <skalibs/types.h> #include <skalibs/allreadwrite.h> #include <skalibs/buffer.h> @@ -21,10 +22,13 @@ #include <skalibs/djbunix.h> #include <skalibs/skamisc.h> #include <skalibs/unix-transactional.h> + #include <execline/execline.h> + #include <s6/config.h> #include <s6/s6-supervise.h> #include <s6/s6-fdholder.h> + #include <s6-rc/config.h> #include <s6-rc/s6rc.h> diff --git a/src/s6-rc/s6-rc.c b/src/s6-rc/s6-rc.c index d92decf..9515a93 100644 --- a/src/s6-rc/s6-rc.c +++ b/src/s6-rc/s6-rc.c @@ -6,6 +6,7 @@ #include <unistd.h> #include <errno.h> #include <signal.h> + #include <skalibs/types.h> #include <skalibs/cdb.h> #include <skalibs/sgetopt.h> @@ -18,8 +19,10 @@ #include <skalibs/selfpipe.h> #include <skalibs/iopause.h> #include <skalibs/unix-transactional.h> + #include <s6/config.h> #include <s6/s6-supervise.h> + #include <s6-rc/config.h> #include <s6-rc/s6rc.h> @@ -43,8 +46,8 @@ static unsigned int n ; static unsigned char *state ; static unsigned int *pendingdeps ; static tain_t deadline ; -static char dryrun[UINT_FMT] = "" ; static unsigned int lameduck = 0 ; +static char dryrun[UINT_FMT] = "" ; static inline void announce (void) { @@ -59,7 +62,7 @@ static inline void announce (void) strerr_diefu2sys(111, "write ", fn) ; } -static int print_services (void) +static inline int print_services (void) { unsigned int i = 0 ; for (; i < n ; i++) @@ -75,7 +78,7 @@ static int print_services (void) strerr_diefu1sys(111, "write to stdout") ; } -static int print_diff (void) +static inline int print_diff (void) { s6_svstatus_t status ; int e = 0 ; @@ -117,7 +120,7 @@ static uint32_t compute_timeout (unsigned int i, int h) return t ; } -static pid_t start_oneshot (unsigned int i, int h) +static inline pid_t start_oneshot (unsigned int i, int h) { unsigned int m = 0 ; char const *newargv[11 + !!dryrun[0] * 8] ; @@ -158,7 +161,7 @@ static pid_t start_oneshot (unsigned int i, int h) return child_spawn0(newargv[0], newargv, (char const *const *)environ) ; } -static pid_t start_longrun (unsigned int i, int h) +static inline pid_t start_longrun (unsigned int i, int h) { size_t svdlen = strlen(db->string + db->services[i].name) ; unsigned int m = 0 ; @@ -201,7 +204,7 @@ static pid_t start_longrun (unsigned int i, int h) return child_spawn0(newargv[0], newargv, (char const *const *)environ) ; } -static void success_longrun (unsigned int i, int h) +static inline void success_longrun (unsigned int i, int h) { if (!dryrun[0]) { @@ -229,7 +232,7 @@ static void success_longrun (unsigned int i, int h) } } -static void failure_longrun (unsigned int i, int h) +static inline void failure_longrun (unsigned int i, int h) { if (h && !dryrun[0]) { @@ -291,7 +294,7 @@ static void broadcast_success (unsigned int i, int h) } } -static void on_success (unsigned int i, int h) +static inline void on_success (unsigned int i, int h) { if (i < db->nlong) success_longrun(i, h) ; if (h) state[i] |= 1 ; else state[i] &= 254 ; @@ -301,7 +304,7 @@ static void on_success (unsigned int i, int h) if (!lameduck) broadcast_success(i, h) ; } -static void on_failure (unsigned int i, int h, int crashed, unsigned int code) +static inline void on_failure (unsigned int i, int h, int crashed, unsigned int code) { if (i < db->nlong) failure_longrun(i, h) ; if (verbosity) @@ -332,7 +335,7 @@ static inline void kill_longruns (void) kill(pidindex[j].pid, SIGTERM) ; } -static int handle_signals (int h) +static inline int handle_signals (int h) { int ok = 1 ; for (;;) |