From 41dec6436242c4daccdd9fdee3ac052004c439bd Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Mon, 16 Mar 2026 21:09:38 +0000 Subject: Refactor ftrig using sass; clean up API a bit, update its users --- src/libs6/deps-exe/s6-ftrigrd | 3 - src/libs6/deps-lib/s6 | 8 +- src/libs6/ftrig1.h | 23 --- src/libs6/ftrig1_free.c | 25 --- src/libs6/ftrig1_make.c | 45 ----- src/libs6/ftrigr-internal.h | 20 +++ src/libs6/ftrigr1_zero.c | 5 - src/libs6/ftrigr_ack.c | 19 +-- src/libs6/ftrigr_check.c | 20 --- src/libs6/ftrigr_checksa.c | 45 ----- src/libs6/ftrigr_end.c | 22 ++- src/libs6/ftrigr_peek.c | 26 +++ src/libs6/ftrigr_peek1.c | 14 ++ src/libs6/ftrigr_release.c | 18 ++ src/libs6/ftrigr_start.c | 10 +- src/libs6/ftrigr_startf.c | 11 +- src/libs6/ftrigr_subscribe.c | 51 +++--- src/libs6/ftrigr_unsubscribe.c | 37 ++-- src/libs6/ftrigr_update.c | 20 ++- src/libs6/ftrigr_updateb.c | 68 -------- src/libs6/ftrigr_wait_and.c | 28 +-- src/libs6/ftrigr_wait_or.c | 25 ++- src/libs6/ftrigr_zero.c | 5 - src/libs6/ftrigw_clean.c | 20 +-- src/libs6/ftrigw_notifyb_nosig.c | 11 +- src/libs6/s6-ftrigrd.c | 312 ++++++++++++---------------------- src/libs6/s6_compat_el_semicolon.c | 34 ++-- src/libs6/s6_supervise_link_names.c | 16 +- src/libs6/s6_supervise_unlink_names.c | 14 +- 29 files changed, 352 insertions(+), 603 deletions(-) delete mode 100644 src/libs6/ftrig1.h delete mode 100644 src/libs6/ftrig1_free.c delete mode 100644 src/libs6/ftrig1_make.c create mode 100644 src/libs6/ftrigr-internal.h delete mode 100644 src/libs6/ftrigr1_zero.c delete mode 100644 src/libs6/ftrigr_check.c delete mode 100644 src/libs6/ftrigr_checksa.c create mode 100644 src/libs6/ftrigr_peek.c create mode 100644 src/libs6/ftrigr_peek1.c create mode 100644 src/libs6/ftrigr_release.c delete mode 100644 src/libs6/ftrigr_updateb.c delete mode 100644 src/libs6/ftrigr_zero.c (limited to 'src/libs6') diff --git a/src/libs6/deps-exe/s6-ftrigrd b/src/libs6/deps-exe/s6-ftrigrd index e6238ab..a11a5f4 100755 --- a/src/libs6/deps-exe/s6-ftrigrd +++ b/src/libs6/deps-exe/s6-ftrigrd @@ -1,5 +1,2 @@ -ftrig1_free.o -ftrig1_make.o -lskarnet -${SOCKET_LIB} ${SYSCLOCK_LIB} diff --git a/src/libs6/deps-lib/s6 b/src/libs6/deps-lib/s6 index 9b1d285..74a30a7 100644 --- a/src/libs6/deps-lib/s6 +++ b/src/libs6/deps-lib/s6 @@ -1,17 +1,15 @@ -ftrigr1_zero.o -ftrigr_check.o -ftrigr_checksa.o ftrigr_ack.o ftrigr_end.o +ftrigr_peek.o +ftrigr_peek1.o +ftrigr_release.o ftrigr_start.o ftrigr_startf.o ftrigr_subscribe.o ftrigr_unsubscribe.o ftrigr_update.o -ftrigr_updateb.o ftrigr_wait_and.o ftrigr_wait_or.o -ftrigr_zero.o ftrigw_clean.o ftrigw_fifodir_make.o ftrigw_notify.o diff --git a/src/libs6/ftrig1.h b/src/libs6/ftrig1.h deleted file mode 100644 index 229de66..0000000 --- a/src/libs6/ftrig1.h +++ /dev/null @@ -1,23 +0,0 @@ -/* ISC license. */ - -#ifndef FTRIG1_H -#define FTRIG1_H - -#include - -#define FTRIG1_PREFIX "ftrig1" -#define FTRIG1_PREFIXLEN (sizeof FTRIG1_PREFIX - 1) - -typedef struct ftrig1_s ftrig1_t, *ftrig1_t_ref ; -struct ftrig1_s -{ - int fd ; - int fdw ; - stralloc name ; -} ; -#define FTRIG1_ZERO { .fd = -1, .fdw = -1, .name = STRALLOC_ZERO } - -extern int ftrig1_make (ftrig1_t *, char const *) ; -extern void ftrig1_free (ftrig1_t *) ; - -#endif diff --git a/src/libs6/ftrig1_free.c b/src/libs6/ftrig1_free.c deleted file mode 100644 index 61c0d1d..0000000 --- a/src/libs6/ftrig1_free.c +++ /dev/null @@ -1,25 +0,0 @@ -/* ISC license. */ - -#include -#include -#include -#include "ftrig1.h" - -void ftrig1_free (ftrig1_t *p) -{ - if (p->name.s) - { - unlink_void(p->name.s) ; - stralloc_free(&p->name) ; - } - if (p->fd >= 0) - { - fd_close(p->fd) ; - p->fd = -1 ; - } - if (p->fdw >= 0) - { - fd_close(p->fdw) ; - p->fdw = -1 ; - } -} diff --git a/src/libs6/ftrig1_make.c b/src/libs6/ftrig1_make.c deleted file mode 100644 index 5c38e4b..0000000 --- a/src/libs6/ftrig1_make.c +++ /dev/null @@ -1,45 +0,0 @@ -/* ISC license. */ - -#include -#include -#include - -#include -#include -#include -#include - -#include "ftrig1.h" - -int ftrig1_make (ftrig1_t *f, char const *path) -{ - ftrig1_t ff = FTRIG1_ZERO ; - size_t pathlen = strlen(path) ; - char tmp[pathlen + FTRIG1_PREFIXLEN + 36] ; - - memcpy(tmp, path, pathlen) ; - tmp[pathlen] = '/' ; tmp[pathlen+1] = '.' ; - memcpy(tmp + pathlen + 2, FTRIG1_PREFIX, FTRIG1_PREFIXLEN) ; - tmp[pathlen + 2 + FTRIG1_PREFIXLEN] = ':' ; - if (!timestamp(tmp + pathlen + 3 + FTRIG1_PREFIXLEN)) return 0 ; - memcpy(tmp + pathlen + FTRIG1_PREFIXLEN + 28, ":XXXXXX", 8) ; - ff.fd = mkptemp3(tmp, 0622, O_NONBLOCK|O_CLOEXEC) ; - if (ff.fd == -1) return 0 ; - ff.fdw = open_write(tmp) ; - if (ff.fdw == -1) goto err1 ; - if (!stralloc_ready(&ff.name, pathlen + FTRIG1_PREFIXLEN + 36)) goto err2 ; - stralloc_copyb(&ff.name, tmp, pathlen + 1) ; - stralloc_catb(&ff.name, tmp + pathlen + 2, FTRIG1_PREFIXLEN + 34) ; - if (rename(tmp, ff.name.s) == -1) goto err3 ; - *f = ff ; - return 1 ; - - err3: - stralloc_free(&ff.name) ; - err2: - fd_close(ff.fdw) ; - err1: - fd_close(ff.fd) ; - unlink_void(tmp) ; - return 0 ; -} diff --git a/src/libs6/ftrigr-internal.h b/src/libs6/ftrigr-internal.h new file mode 100644 index 0000000..dc9e442 --- /dev/null +++ b/src/libs6/ftrigr-internal.h @@ -0,0 +1,20 @@ +/* ISC license. */ + +#ifndef FTRIGR_INTERNAL_H +#define FTRIGR_INTERNAL_H + +#include + +#define FTRIGR_BANNER1 "ftrigr v2.0 (b)\n" +#define FTRIGR_BANNER2 "ftrigr v2.0 (a)\n" + +typedef struct ftrigr_data_s ftrigr_data, *ftrigr_data_ref ; +struct ftrigr_data_s +{ + int status ; + stralloc sa ; +} ; +#define FTRIGR_DATA_ZERO { .id = 0, .status = 0, .sa = STRALLOC_ZERO } + + +#endif diff --git a/src/libs6/ftrigr1_zero.c b/src/libs6/ftrigr1_zero.c deleted file mode 100644 index 967b4e0..0000000 --- a/src/libs6/ftrigr1_zero.c +++ /dev/null @@ -1,5 +0,0 @@ -/* ISC license. */ - -#include - -ftrigr1_t const ftrigr1_zero = FTRIGR1_ZERO ; diff --git a/src/libs6/ftrigr_ack.c b/src/libs6/ftrigr_ack.c index 5c9a9f3..ac5ee7c 100644 --- a/src/libs6/ftrigr_ack.c +++ b/src/libs6/ftrigr_ack.c @@ -1,17 +1,16 @@ /* ISC license. */ -#include +#include + #include + #include +#include "ftrigr-internal.h" -void ftrigr_ack (ftrigr_t *a, size_t n) +int ftrigr_ack (ftrigr *a, uint32_t id) { - size_t len = genalloc_len(uint16_t, &a->list) ; - a->head += n ; - if (a->head > len) a->head = len ; - if (a->head == len) - { - a->head = 0 ; - genalloc_setlen(uint16_t, &a->list, 0) ; - } + ftrigr_data *p = genalloc_s(ftrigr_data, &a->data) + id ; + if (p->status && p->status != EAGAIN) return (errno = p->status, 0) ; + p->sa.len = 0 ; + return 1 ; } diff --git a/src/libs6/ftrigr_check.c b/src/libs6/ftrigr_check.c deleted file mode 100644 index 30be701..0000000 --- a/src/libs6/ftrigr_check.c +++ /dev/null @@ -1,20 +0,0 @@ -/* ISC license. */ - -#include -#include -#include - -int ftrigr_check (ftrigr_t *a, uint16_t id, char *c) -{ - stralloc sa = STRALLOC_ZERO ; - int r = ftrigr_checksa(a, id, &sa) ; - - if (r && sa.len) - { - int e = errno ; - *c = sa.s[sa.len - 1] ; - stralloc_free(&sa) ; - errno = e ; - } - return r ; -} diff --git a/src/libs6/ftrigr_checksa.c b/src/libs6/ftrigr_checksa.c deleted file mode 100644 index 6573182..0000000 --- a/src/libs6/ftrigr_checksa.c +++ /dev/null @@ -1,45 +0,0 @@ -/* ISC license. */ - -#include -#include -#include -#include - -int ftrigr_checksa (ftrigr_t *a, uint16_t id, stralloc *sa) -{ - ftrigr1_t *p ; - if (!id--) return (errno = EINVAL, -1) ; - p = GENSETDYN_P(ftrigr1_t, &a->data, id) ; - if (!p) return (errno = EINVAL, -1) ; - switch (p->state) - { - case FR1STATE_WAITACKDATA : - { - if (!stralloc_catb(sa, p->what.s, p->what.len)) return -1 ; - stralloc_free(&p->what) ; - *p = ftrigr1_zero ; - gensetdyn_delete(&a->data, id) ; - return 1 ; - } - case FR1STATE_LISTENING : - { - if (!p->what.len) break ; - if (!stralloc_catb(sa, p->what.s, p->what.len)) return -1 ; - p->what.len = 0 ; - return 1 ; - } - case FR1STATE_WAITACK : - { - int e ; - if (!stralloc_catb(sa, p->what.s, p->what.len - 1)) return -1 ; - e = p->what.s[p->what.len - 1] ; - stralloc_free(&p->what) ; - *p = ftrigr1_zero ; - gensetdyn_delete(&a->data, id) ; - errno = e ; - return -1 ; - } - default: return (errno = EINVAL, -1) ; - } - return 0 ; -} diff --git a/src/libs6/ftrigr_end.c b/src/libs6/ftrigr_end.c index 555053f..5c0eb13 100644 --- a/src/libs6/ftrigr_end.c +++ b/src/libs6/ftrigr_end.c @@ -1,15 +1,21 @@ /* ISC license. */ -#include +#include #include -#include -#include +#include + #include +#include "ftrigr-internal.h" + +static void ftrigr_data_free (void *x) +{ + ftrigr_data *p = x ; + stralloc_free(&p->sa) ; +} -void ftrigr_end (ftrigr_ref a) +void ftrigr_end (ftrigr *a) { - gensetdyn_free(&a->data) ; - genalloc_free(uint16_t, &a->list) ; - textclient_end(&a->connection) ; - *a = ftrigr_zero ; + sassclient_end(&a->client) ; + a->data.len = a->data.a ; + genalloc_deepfree(ftrigr_data, &a->data, &ftrigr_data_free) ; } diff --git a/src/libs6/ftrigr_peek.c b/src/libs6/ftrigr_peek.c new file mode 100644 index 0000000..155fce3 --- /dev/null +++ b/src/libs6/ftrigr_peek.c @@ -0,0 +1,26 @@ +/* ISC license. */ + +#include +#include + +#include + +#include +#include "ftrigr-internal.h" + +int ftrigr_peek (ftrigr *a, uint32_t id, struct iovec *v) +{ + ftrigr_data *p = genalloc_s(ftrigr_data, &a->data) + id ; + switch (p->status) + { + case EAGAIN : return 0 ; + case 0 : + { + v->iov_base = p->sa.s ; + v->iov_len = p->sa.len ; + return 1 ; + } + default: break ; + } + return (errno = p->status, -1) ; +} diff --git a/src/libs6/ftrigr_peek1.c b/src/libs6/ftrigr_peek1.c new file mode 100644 index 0000000..81059f7 --- /dev/null +++ b/src/libs6/ftrigr_peek1.c @@ -0,0 +1,14 @@ +/* ISC license. */ + +#include + +#include + +int ftrigr_peek1 (ftrigr *a, uint32_t id, char *c) +{ + struct iovec v ; + int r = ftrigr_peek(a, id, &v) ; + if (r <= 0) return r ; + *c = ((char *)v.iov_base)[v.iov_len - 1] ; + return 1 ; +} diff --git a/src/libs6/ftrigr_release.c b/src/libs6/ftrigr_release.c new file mode 100644 index 0000000..fdcd9d0 --- /dev/null +++ b/src/libs6/ftrigr_release.c @@ -0,0 +1,18 @@ +/* ISC license. */ + +#include +#include + +#include +#include + +#include +#include "ftrigr-internal.h" + +void ftrigr_release (ftrigr *a, uint32_t id) +{ + ftrigr_data *p = genalloc_s(ftrigr_data, &a->data) + id ; + sassclient_release(&a->client, id) ; + p->status = EINVAL ; + p->sa.len = 0 ; +} diff --git a/src/libs6/ftrigr_start.c b/src/libs6/ftrigr_start.c index c4422dc..cf73573 100644 --- a/src/libs6/ftrigr_start.c +++ b/src/libs6/ftrigr_start.c @@ -1,9 +1,13 @@ /* ISC license. */ -#include +#include + #include -int ftrigr_start (ftrigr_t *a, char const *path, tain const *deadline, tain *stamp) +int ftrigr_start (ftrigr *a, unsigned int sec) { - return textclient_start(&a->connection, path, 0, FTRIGR_BANNER1, FTRIGR_BANNER1_LEN, FTRIGR_BANNER2, FTRIGR_BANNER2_LEN, deadline, stamp) ; + tain deadline = TAIN_INFINITE ; + if (!tain_now_set_stopwatch_g()) return 0 ; + if (sec) tain_addsec_g(&deadline, sec) ; + return ftrigr_startf_g(a, &deadline) ; } diff --git a/src/libs6/ftrigr_startf.c b/src/libs6/ftrigr_startf.c index bc503ba..5ebf6ce 100644 --- a/src/libs6/ftrigr_startf.c +++ b/src/libs6/ftrigr_startf.c @@ -1,12 +1,13 @@ /* ISC license. */ -#include -#include +#include +#include #include +#include "ftrigr-internal.h" -int ftrigr_startf (ftrigr_t *a, tain const *deadline, tain *stamp) +int ftrigr_startf (ftrigr *a, tain const *deadline, tain *stamp) { - static char const *const cargv[2] = { FTRIGRD_PROG, 0 } ; - return textclient_startf(&a->connection, cargv, (char const *const *)environ, TEXTCLIENT_OPTION_WAITPID, FTRIGR_BANNER1, FTRIGR_BANNER1_LEN, FTRIGR_BANNER2, FTRIGR_BANNER2_LEN, deadline, stamp) ; + char const *argv[2] = { S6_LIBEXECPREFIX "s6-ftrigrd", 0 } ; + return sassclient_start(&a->client, argv, FTRIGR_BANNER1, FTRIGR_BANNER2, deadline, stamp) ; } diff --git a/src/libs6/ftrigr_subscribe.c b/src/libs6/ftrigr_subscribe.c index 1dc86e7..eb1d365 100644 --- a/src/libs6/ftrigr_subscribe.c +++ b/src/libs6/ftrigr_subscribe.c @@ -2,41 +2,42 @@ #include #include -#include #include -#include -#include -#include -#include -#include -#include + #include +#include "ftrigr-internal.h" + +static int ftrigr_cb (char const *s, size_t len, uint32_t id, void *x) +{ + ftrigr_data *p = genalloc_s(ftrigr_data, (genalloc *)x) + id ; + if (!stralloc_catb(&p->sa, s, len)) return errno ; + p->status = 0 ; + return 0 ; +} -uint16_t ftrigr_subscribe (ftrigr_t *a, char const *path, char const *re, uint32_t options, tain const *deadline, tain *stamp) +int ftrigr_subscribe (ftrigr *a, uint32_t *i, uint32_t flags, uint32_t timeout, char const *path, char const *re, tain const *deadline, tain *stamp) { + ftrigr_data *p ; + uint32_t id ; size_t pathlen = strlen(path) ; size_t relen = strlen(re) ; - ftrigr1_t ft = { .options = options, .state = FR1STATE_LISTENING, .what = STRALLOC_ZERO } ; - uint32_t i ; - char tmp[15] = "--L" ; - struct iovec v[3] = { { .iov_base = tmp, .iov_len = 15 }, { .iov_base = (char *)path, .iov_len = pathlen + 1 }, { .iov_base = (char *)re, .iov_len = relen + 1 } } ; - if (!gensetdyn_new(&a->data, &i)) return 0 ; - if (i >= UINT16_MAX) + + struct iovec v[2] = { - gensetdyn_delete(&a->data, i) ; - return (errno = EMFILE, 0) ; - } - uint16_pack_big(tmp, (uint16_t)i) ; - uint32_pack_big(tmp+3, options) ; - uint32_pack_big(tmp+7, (uint32_t)pathlen) ; - uint32_pack_big(tmp+11, (uint32_t)relen) ; - if (!textclient_commandv(&a->connection, v, 3, deadline, stamp)) + { .iov_base = (char *)path, .iov_len = pathlen + 1 }, + { .iov_base = (char *)re, .iov_len = relen + 1 } + } ; + if (!sassclient_sendv(&a->client, &id, flags, timeout, 0, v, 2, &ftrigr_cb, &a->data, deadline, stamp)) return 0 ; + if (!genalloc_ready(ftrigr_data, &a->data, id + 1)) { int e = errno ; - gensetdyn_delete(&a->data, i) ; + sassclient_cancel(&a->client, id, deadline, stamp) ; errno = e ; return 0 ; } - *GENSETDYN_P(ftrigr1_t, &a->data, i) = ft ; - return (uint16_t)(i+1) ; + p = genalloc_s(ftrigr_data, &a->data) + id ; + p->sa.len = 0 ; + p->status = EAGAIN ; + *i = id ; + return 1 ; } diff --git a/src/libs6/ftrigr_unsubscribe.c b/src/libs6/ftrigr_unsubscribe.c index 8a716d5..9aa5595 100644 --- a/src/libs6/ftrigr_unsubscribe.c +++ b/src/libs6/ftrigr_unsubscribe.c @@ -1,33 +1,18 @@ /* ISC license. */ #include -#include -#include -#include -#include + +#include + #include +#include "ftrigr-internal.h" -int ftrigr_unsubscribe (ftrigr_t *a, uint16_t i, tain const *deadline, tain *stamp) +int ftrigr_unsubscribe (ftrigr *a, uint32_t id, tain const *deadline, tain *stamp) { - ftrigr1_t *p ; - char pack[3] = "--U" ; - if (!i--) return (errno = EINVAL, 0) ; - p = GENSETDYN_P(ftrigr1_t, &a->data, i) ; - if (!p) return (errno = EINVAL, 0) ; - switch (p->state) - { - case FR1STATE_WAITACK : - case FR1STATE_WAITACKDATA : - { - char dummy ; - ftrigr_check(a, i+1, &dummy) ; - return 1 ; - } - default : break ; - } - uint16_pack_big(pack, i) ; - if (!textclient_command(&a->connection, pack, 3, deadline, stamp)) return 0 ; - stralloc_free(&p->what) ; - *p = ftrigr1_zero ; - return gensetdyn_delete(&a->data, i) ; + ftrigr_data *p ; + if (!sassclient_cancel(&a->client, id, deadline, stamp)) return 0 ; + p = genalloc_s(ftrigr_data, &a->data) + id ; + p->sa.len = 0 ; + p->status = EINVAL ; + return 1 ; } diff --git a/src/libs6/ftrigr_update.c b/src/libs6/ftrigr_update.c index 674d8cb..afae759 100644 --- a/src/libs6/ftrigr_update.c +++ b/src/libs6/ftrigr_update.c @@ -1,11 +1,25 @@ /* ISC license. */ #include + #include +#include + #include +#include "ftrigr-internal.h" -int ftrigr_update (ftrigr_t *a) +int ftrigr_update (ftrigr *a) { - genalloc_setlen(uint16_t, &a->list, 0) ; - return ftrigr_updateb(a) ; + int r = sassclient_update(&a->client) ; + if (r <= 0) return r ; + for (;;) + { + uint32_t id ; + int status ; + r = sassclient_ack(&a->client, &id, &status) ; + if (r == -1) return -1 ; + if (!r) break ; + genalloc_s(ftrigr_data, &a->data)[id].status = status ; + } + return 1 ; } diff --git a/src/libs6/ftrigr_updateb.c b/src/libs6/ftrigr_updateb.c deleted file mode 100644 index 2a47e49..0000000 --- a/src/libs6/ftrigr_updateb.c +++ /dev/null @@ -1,68 +0,0 @@ -/* ISC license. */ - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -static inline int appears (uint16_t, uint16_t const *, size_t) gccattr_pure ; - -static inline int appears (uint16_t id, uint16_t const *list, size_t len) -{ - while (len) if (id == list[--len]) return 1 ; - return 0 ; -} - -static int msghandler (struct iovec const *v, void *context) -{ - ftrigr_t *a = (ftrigr_t *)context ; - ftrigr1_t *p ; - int addit = 1 ; - char const *s = v->iov_base ; - uint16_t id ; - if (v->iov_len != 4) return (errno = EPROTO, 0) ; - uint16_unpack_big(s, &id) ; - p = GENSETDYN_P(ftrigr1_t, &a->data, id) ; - if (!p) return 1 ; - if (p->state != FR1STATE_LISTENING) return (errno = EINVAL, 0) ; - if (!genalloc_readyplus(uint16_t, &a->list, 1)) return 0 ; - switch (s[2]) - { - case 'd' : - if (!stralloc_catb(&p->what, s + 3, 1)) return 0 ; - p->state = FR1STATE_WAITACK ; - break ; - case '!' : - if (!stralloc_catb(&p->what, s + 3, 1)) return 0 ; - if (p->options & FTRIGR_REPEAT) - { - if (p->what.len > 1 - && appears(id+1, genalloc_s(uint16_t, &a->list), genalloc_len(uint16_t, &a->list))) - addit = 0 ; - } - else p->state = FR1STATE_WAITACKDATA ; - break ; - default : return (errno = EPROTO, 0) ; - } - if (addit) - { - id++ ; genalloc_append(uint16_t, &a->list, &id) ; - } - return 1 ; -} - -int ftrigr_updateb (ftrigr_t *a) -{ - size_t curlen = genalloc_len(uint16_t, &a->list) ; - int r = textclient_update(&a->connection, &msghandler, a) ; - return r < 0 ? r : (int)(genalloc_len(uint16_t, &a->list) - curlen) ; -} diff --git a/src/libs6/ftrigr_wait_and.c b/src/libs6/ftrigr_wait_and.c index ebdbde0..24e722f 100644 --- a/src/libs6/ftrigr_wait_and.c +++ b/src/libs6/ftrigr_wait_and.c @@ -1,27 +1,29 @@ /* ISC license. */ +#include #include + #include + #include -int ftrigr_wait_and (ftrigr_t *a, uint16_t const *idlist, unsigned int n, tain const *deadline, tain *stamp) +int ftrigr_wait_and (ftrigr *a, uint32_t const *list, unsigned int n, tain const *deadline, tain *stamp) { - iopause_fd x = { -1, IOPAUSE_READ, 0 } ; - x.fd = ftrigr_fd(a) ; - for (; n ; n--, idlist++) + iopause_fd x = { .fd = ftrigr_fd(a), .events = IOPAUSE_READ } ; + for (unsigned int i = 0 ; i < n ; i++) { for (;;) { - char dummy ; - int r = ftrigr_check(a, *idlist, &dummy) ; - if (r < 0) return r ; - else if (r) break ; + struct iovec v ; + int r = ftrigr_peek(a, list[i], &v) ; + if (r == -1) return -1 ; + if (r) break ; r = iopause_stamp(&x, 1, deadline, stamp) ; - if (r < 0) return r ; - else if (!r) return (errno = ETIMEDOUT, -1) ; - else if (ftrigr_updateb(a) < 0) return -1 ; + if (r == -1) return -1 ; + if (!r) return (errno = ETIMEDOUT, -1) ; + if (ftrigr_update(a) == -1) return -1 ; } + ftrigr_ack(a, list[i]) ; } - - return 1 ; + return 0 ; } diff --git a/src/libs6/ftrigr_wait_or.c b/src/libs6/ftrigr_wait_or.c index efe6e14..0ed41b7 100644 --- a/src/libs6/ftrigr_wait_or.c +++ b/src/libs6/ftrigr_wait_or.c @@ -1,32 +1,27 @@ /* ISC license. */ +#include #include #include #include -#include - -int ftrigr_wait_or (ftrigr_t *a, uint16_t const *idlist, unsigned int n, tain const *deadline, tain *stamp, char *c) +int ftrigr_wait_or (ftrigr *a, uint32_t const *list, unsigned int n, struct iovec *v, tain const *deadline, tain *stamp) { - iopause_fd x = { -1, IOPAUSE_READ | IOPAUSE_EXCEPT, 0 } ; - x.fd = ftrigr_fd(a) ; - if (x.fd < 0) return -1 ; + iopause_fd x = { .fd = ftrigr_fd(a), .events = IOPAUSE_READ } ; for (;;) { - unsigned int i = 0 ; int r ; - for (; i < n ; i++) + for (unsigned int i = 0 ; i < n ; i++) { - r = ftrigr_check(a, idlist[i], c) ; - if (r < 0) return r ; - else if (r) return i ; + r = ftrigr_peek(a, list[i], v) ; + if (r == -1) return -1 ; + if (r) return i ; } r = iopause_stamp(&x, 1, deadline, stamp) ; - if (r < 0) return 0 ; - else if (!r) return (errno = ETIMEDOUT, -1) ; - else if (ftrigr_update(a) < 0) return -1 ; + if (r == -1) return -1 ; + if (!r) return (errno = ETIMEDOUT, -1) ; + if (ftrigr_update(a) == -1) return -1 ; } - return (errno = EPROTO, -1) ; /* can't happen */ } diff --git a/src/libs6/ftrigr_zero.c b/src/libs6/ftrigr_zero.c deleted file mode 100644 index b09ddb6..0000000 --- a/src/libs6/ftrigr_zero.c +++ /dev/null @@ -1,5 +0,0 @@ -/* ISC license. */ - -#include - -ftrigr_t const ftrigr_zero = FTRIGR_ZERO ; diff --git a/src/libs6/ftrigw_clean.c b/src/libs6/ftrigw_clean.c index e540aba..301fd39 100644 --- a/src/libs6/ftrigw_clean.c +++ b/src/libs6/ftrigw_clean.c @@ -3,21 +3,22 @@ #include #include #include + +#include #include #include -#include "ftrig1.h" + #include int ftrigw_clean (char const *path) { size_t pathlen = strlen(path) ; - int e = 0 ; DIR *dir = opendir(path) ; if (!dir) return 0 ; { - char tmp[pathlen + FTRIG1_PREFIXLEN + 35] ; + char tmp[pathlen + 41] ; memcpy(tmp, path, pathlen) ; - tmp[pathlen] = '/' ; tmp[pathlen + FTRIG1_PREFIXLEN + 34] = 0 ; + tmp[pathlen] = '/' ; tmp[pathlen + 40] = 0 ; for (;;) { direntry *d ; @@ -25,15 +26,14 @@ int ftrigw_clean (char const *path) errno = 0 ; d = readdir(dir) ; if (!d) break ; - if (strncmp(d->d_name, FTRIG1_PREFIX, FTRIG1_PREFIXLEN)) continue ; - if (strlen(d->d_name) != FTRIG1_PREFIXLEN + 33) continue ; - memcpy(tmp + pathlen + 1, d->d_name, FTRIG1_PREFIXLEN + 33) ; + if (strncmp(d->d_name, "ftrig1", 6)) continue ; + if (strlen(d->d_name) != 39) continue ; + memcpy(tmp + pathlen + 1, d->d_name, 39) ; fd = open_write(tmp) ; if (fd >= 0) fd_close(fd) ; - else if ((errno == ENXIO) && (unlink(tmp) < 0)) e = errno ; + else if (errno == ENXIO) unlink_void(tmp) ; } } dir_close(dir) ; - if (errno) e = errno ; - return e ? (errno = e, 0) : 1 ; + return !errno ; } diff --git a/src/libs6/ftrigw_notifyb_nosig.c b/src/libs6/ftrigw_notifyb_nosig.c index 103e2b9..06abae6 100644 --- a/src/libs6/ftrigw_notifyb_nosig.c +++ b/src/libs6/ftrigw_notifyb_nosig.c @@ -10,7 +10,6 @@ #include #include -#include "ftrig1.h" int ftrigw_notifyb_nosig (char const *path, char const *s, size_t len) { @@ -19,10 +18,10 @@ int ftrigw_notifyb_nosig (char const *path, char const *s, size_t len) if (!dir) return -1 ; { size_t pathlen = strlen(path) ; - char tmp[pathlen + FTRIG1_PREFIXLEN + 35] ; + char tmp[pathlen + 41] ; memcpy(tmp, path, pathlen) ; tmp[pathlen] = '/' ; - tmp[pathlen + FTRIG1_PREFIXLEN + 34] = 0 ; + tmp[pathlen + 40] = 0 ; for (;;) { direntry *d ; @@ -30,9 +29,9 @@ int ftrigw_notifyb_nosig (char const *path, char const *s, size_t len) errno = 0 ; d = readdir(dir) ; if (!d) break ; - if (strncmp(d->d_name, FTRIG1_PREFIX ":@", FTRIG1_PREFIXLEN + 2)) continue ; - if (strlen(d->d_name) != FTRIG1_PREFIXLEN + 33) continue ; - memcpy(tmp + pathlen + 1, d->d_name, FTRIG1_PREFIXLEN + 33) ; + if (strncmp(d->d_name, "ftrig1:@", 8)) continue ; + if (strlen(d->d_name) != 39) continue ; + memcpy(tmp + pathlen + 1, d->d_name, 39) ; fd = open_write(tmp) ; if (fd == -1) { diff --git a/src/libs6/s6-ftrigrd.c b/src/libs6/s6-ftrigrd.c index 5b5ffd9..a037e31 100644 --- a/src/libs6/s6-ftrigrd.c +++ b/src/libs6/s6-ftrigrd.c @@ -1,293 +1,207 @@ /* ISC license. */ -#include #include #include +#include #include +#include #include #include +#include #include -#include #include -#include -#include #include -#include +#include #include -#include #include #include #include #include -#include -#include +#include -#include "ftrig1.h" -#include +#include "ftrigr-internal.h" #include #define FTRIGRD_MAXREADS 32 -#define FTRIGRD_BUFSIZE 16 +#define FTRIGRD_BUFSIZE 32 #define dienomem() strerr_diefu1sys(111, "stralloc_catb") typedef struct ftrigio_s ftrigio, *ftrigio_ref ; struct ftrigio_s { + ftrigio_ref prev ; + ftrigio_ref next ; unsigned int xindex ; - ftrig1_t trig ; + uint32_t id ; + uint32_t flags ; buffer b ; - regex_t re ; + char buf[FTRIGRD_BUFSIZE] ; + int fdw ; + size_t start ; stralloc sa ; - uint32_t options ; - uint16_t id ; /* given by client */ + regex_t re ; } ; -#define FTRIGIO_ZERO { .xindex = 0, .trig = FTRIG1_ZERO, .b = BUFFER_INIT(0, -1, 0, 0), .buf = "", .sa = STRALLOC_ZERO, .options = 0, .id = 0 } +#define FTRIGIO_ZERO { .prev = 0, .next = 0, .xindex = 0, .id = 0, .flags = 0, .b = BUFFER_INIT(0, -1, 0, 0), .buf = "", .fdw = -1, .start = 0, .sa = STRALLOC_ZERO } -static genalloc g = GENALLOC_ZERO ; /* ftrigio */ +static ftrigio ftrigio_head = { .prev = &ftrigio_head, .next = &ftrigio_head, .start = 0, .sa = STRALLOC_ZERO } ; +#define numio (ftrigio_head.start) -static void ftrigio_free (ftrigio *p) +static void cleanup (void *x) { - alloc_free(p->b.c.x) ; - ftrig1_free(&p->trig) ; - stralloc_free(&p->sa) ; - regfree(&p->re) ; + (void)x ; + for (ftrigio *p = ftrigio_head.next ; p != &ftrigio_head ; p = p->next) + unlink_void(p->sa.s) ; } -static void cleanup (void) +static void ftrigio_remove (void *x) { - size_t n = genalloc_len(ftrigio, &g) ; - ftrigio *a = genalloc_s(ftrigio, &g) ; - for (size_t i = 0 ; i < n ; i++) ftrigio_free(a + i) ; - genalloc_setlen(ftrigio, &g, 0) ; + ftrigio *p = x ; + p->next->prev = p->prev ; + p->prev->next = p->next ; + numio-- ; + p->prev = p->next = 0 ; + unlink_void(p->sa.s) ; + fd_close(p->fdw) ; + fd_close(buffer_fd(&p->b)) ; + p->sa.len = 0 ; + regfree(&p->re) ; } -static void trig (uint16_t id, char what, char info) +static int ftrigio_add (void *x, uint32_t id, uint32_t flags, uint32_t opcode, char const *s, size_t len) { - char pack[4] ; - uint16_pack_big(pack, id) ; - pack[2] = what ; pack[3] = info ; - if (!textmessage_put(textmessage_sender_x, pack, 4)) - { - cleanup() ; - strerr_diefu1sys(111, "build answer") ; - } -} + ftrigio *p = x ; + size_t pathlen ; + if (len < 3 || s[len - 1]) return EPROTO ; + pathlen = strlen(s) ; + if (pathlen + 1 >= len) return EPROTO ; + p->start = pathlen + 41 ; + if (!stralloc_ready(&p->sa, p->start)) { cleanup(0) ; dienomem() ; } -static void answer (unsigned char c) -{ - if (!textmessage_put(textmessage_sender_1, (char *)&c, 1)) { - cleanup() ; - strerr_diefu1sys(111, "textmessage_put") ; + char tmp[p->start + 1] ; + int r = skalibs_regcomp(&p->re, s + pathlen + 1, REG_EXTENDED) ; + if (r) return r == REG_ESPACE ? ENOMEM : EINVAL ; + memcpy(tmp, s, pathlen) ; + memcpy(tmp + pathlen, "/.ftrig1:", 9) ; + if (!timestamp(tmp + pathlen + 9)) goto err0 ; + memcpy(tmp + pathlen + 34, ":XXXXXX", 8) ; + r = mkptemp3(tmp, 0622, O_NONBLOCK | O_CLOEXEC) ; + if (r == -1) goto err0 ; + buffer_init(&p->b, &buffer_read, r, p->buf, FTRIGRD_BUFSIZE) ; + p->fdw = open_write(tmp) ; + if (p->fdw == -1) { unlink_void(tmp) ; goto err1 ; } + stralloc_copyb(&p->sa, tmp, pathlen + 1) ; + stralloc_catb(&p->sa, tmp + pathlen + 2, 40) ; + if (rename(tmp, p->sa.s) == -1) { unlink_void(tmp) ; goto err2 ; } } -} + + p->id = id ; + p->flags = flags ; + p->prev = &ftrigio_head ; + p->next = ftrigio_head.next ; + ftrigio_head.next = p ; + numio++ ; + (void)opcode ; + return 0 ; -static void ftrigio_remove (size_t i) -{ - size_t n = genalloc_len(ftrigio, &g) ; - ftrigio *a = genalloc_s(ftrigio, &g) ; - ftrigio_free(a + i) ; - a[i] = a[--n] ; - genalloc_setlen(ftrigio, &g, n) ; + err2: + fd_close(p->fdw) ; + err1: + fd_close(buffer_fd(&p->b)) ; + err0: + regfree(&p->re) ; + return errno ; } -static inline int ftrigio_read (ftrigio *p) +static inline int ftrigio_read (sassserver *a, ftrigio *p) { unsigned int i = FTRIGRD_MAXREADS ; while (i--) { - regmatch_t pmatch ; size_t blen ; ssize_t r = sanitize_read(buffer_fill(&p->b)) ; if (!r) break ; - if (r < 0) return (trig(p->id, 'd', errno), 0) ; - blen = buffer_len(&p->b) ; - if (!stralloc_readyplus(&p->sa, blen+1)) + if (r == -1) { - cleanup() ; - dienomem() ; + sassserver_async_failure(a, p->id, errno) ; + return 0 ; } + blen = buffer_len(&p->b) ; + if (!stralloc_readyplus(&p->sa, blen+1)) { cleanup(0) ; dienomem() ; } buffer_getnofill(&p->b, p->sa.s + p->sa.len, blen) ; p->sa.len += blen ; p->sa.s[p->sa.len] = 0 ; - while (!regexec(&p->re, p->sa.s, 1, &pmatch, REG_NOTBOL | REG_NOTEOL)) - { - trig(p->id, '!', p->sa.s[pmatch.rm_eo - 1]) ; - if (!(p->options & FTRIGR_REPEAT)) return 0 ; - memmove(p->sa.s, p->sa.s + pmatch.rm_eo, p->sa.len + 1 - pmatch.rm_eo) ; - p->sa.len -= pmatch.rm_eo ; - } - } - return 1 ; -} - -static int parse_protocol (struct iovec const *v, void *context) -{ - char const *s = v->iov_base ; - uint16_t id ; - if (v->iov_len < 3) - { - cleanup() ; - strerr_dief1x(100, "invalid client request") ; - } - uint16_unpack_big(s, &id) ; - switch (s[2]) - { - case 'U' : /* unsubscribe */ - { - size_t n = genalloc_len(ftrigio, &g) ; - size_t i = 0 ; - for (; i < n ; i++) if (genalloc_s(ftrigio, &g)[i].id == id) break ; - if (i < n) - { - ftrigio_remove(i) ; - answer(0) ; - } - else answer(EINVAL) ; - break ; - } - case 'L' : /* subscribe to path and match re */ + if (!regexec(&p->re, p->sa.s + p->start, 0, 0, 0)) { - size_t n = genalloc_len(ftrigio, &g) ; - ftrigio *p ; - char *x ; - uint32_t options, pathlen, relen ; - int r ; - if (v->iov_len < 19) - { - answer(EPROTO) ; - break ; - } - uint32_unpack_big(s + 3, &options) ; - uint32_unpack_big(s + 7, &pathlen) ; - uint32_unpack_big(s + 11, &relen) ; - if (((pathlen + relen + 17) != v->iov_len) || s[15 + pathlen] || s[v->iov_len - 1]) - { - answer(EPROTO) ; - break ; - } - if (!genalloc_readyplus(ftrigio, &g, 1)) - { - answer(ENOMEM) ; - break ; - } - x = alloc(FTRIGRD_BUFSIZE) ; - if (!x) - { - answer(ENOMEM) ; - break ; - } - p = genalloc_s(ftrigio, &g) + n ; - r = skalibs_regcomp(&p->re, s + 16 + pathlen, REG_EXTENDED) ; - if (r) - { - alloc_free(x) ; - answer(r == REG_ESPACE ? ENOMEM : EINVAL) ; - break ; - } - if (!ftrig1_make(&p->trig, s + 15)) - { - regfree(&p->re) ; - alloc_free(x) ; - answer(errno) ; - break ; - } - buffer_init(&p->b, &buffer_read, p->trig.fd, x, FTRIGRD_BUFSIZE) ; - p->options = options ; - p->id = id ; - p->sa = stralloc_zero ; - genalloc_setlen(ftrigio, &g, n+1) ; - answer(0) ; - break ; + sassserver_async_success(a, p->id, p->flags, p->sa.s + p->start, p->sa.len - p->start) ; + p->sa.len = p->start ; } - default : - cleanup() ; - strerr_dief1x(100, "invalid client request") ; } - (void)context ; return 1 ; } int main (void) { + sassserver a = SASSSERVER_ZERO ; + int r = 0 ; PROG = "s6-ftrigrd" ; if (ndelay_on(0) == -1 || ndelay_on(1) == -1) strerr_diefu1sys(111, "make fds nonblocking") ; if (!sig_altignore(SIGPIPE)) strerr_diefu1sys(111, "ignore SIGPIPE") ; + if (!tain_now_set_stopwatch_g()) + strerr_diefu1sys(111, "tain_now_set_stopwatch") ; { tain deadline ; - tain_now_set_stopwatch_g() ; - tain_addsec_g(&deadline, 2) ; - if (!textclient_server_01x_init_g(FTRIGR_BANNER1, FTRIGR_BANNER1_LEN, FTRIGR_BANNER2, FTRIGR_BANNER2_LEN, &deadline)) - strerr_diefu1sys(111, "sync with client") ; + tain_addsec_g(&deadline, 5) ; + sassserver_init_g(&a, FTRIGR_BANNER1, FTRIGR_BANNER2, &ftrigio_add, &ftrigio_remove, sizeof(ftrigio), &cleanup, 0, &deadline) ; } - for (;;) + while (!r) { - size_t n = genalloc_len(ftrigio, &g) ; - size_t i = 0 ; - iopause_fd x[3 + n] ; + tain deadline = TAIN_INFINITE ; + iopause_fd x[3 + numio] ; + + sassserver_prepare_iopause(&a, x, &deadline) ; - x[0].fd = 0 ; x[0].events = IOPAUSE_EXCEPT | IOPAUSE_READ ; - x[1].fd = 1 ; x[1].events = IOPAUSE_EXCEPT | (textmessage_sender_isempty(textmessage_sender_1) ? 0 : IOPAUSE_WRITE) ; - x[2].fd = textmessage_sender_fd(textmessage_sender_x) ; - x[2].events = IOPAUSE_EXCEPT | (textmessage_sender_isempty(textmessage_sender_x) ? 0 : IOPAUSE_WRITE) ; - for (; i < n ; i++) + for (ftrigio *p = ftrigio_head.next ; p != &ftrigio_head ; p = p->next, r++) { - ftrigio *p = genalloc_s(ftrigio, &g) + i ; - p->xindex = 3+i ; - x[3+i].fd = p->trig.fd ; - x[3+i].events = IOPAUSE_READ ; + p->xindex = 3+r ; + x[3+r].fd = buffer_fd(&p->b) ; + x[3+r].events = IOPAUSE_READ ; } - if (iopause(x, 3 + n, 0, 0) < 0) + r = iopause_g(x, 3 + numio, &deadline) ; + if (r == -1) { - cleanup() ; + cleanup(0) ; strerr_diefu1sys(111, "iopause") ; } - - /* client closed */ - if ((x[0].revents | x[1].revents) & IOPAUSE_EXCEPT) break ; - - /* client is reading */ - if (x[1].revents & IOPAUSE_WRITE) - if (!textmessage_sender_flush(textmessage_sender_1) && !error_isagain(errno)) - { - cleanup() ; - strerr_diefu1sys(111, "flush stdout") ; - } - if (x[2].revents & IOPAUSE_WRITE) - if (!textmessage_sender_flush(textmessage_sender_x) && !error_isagain(errno)) - { - cleanup() ; - return 1 ; - } - - /* scan listening ftrigs */ - for (i = 0 ; i < genalloc_len(ftrigio, &g) ; i++) + if (!r) { - ftrigio *p = genalloc_s(ftrigio, &g) + i ; - if (x[p->xindex].revents & IOPAUSE_READ) - if (!ftrigio_read(p)) ftrigio_remove(i--) ; + sassserver_timeout(&a) ; + continue ; } - /* client is writing */ - if (!textmessage_receiver_isempty(textmessage_receiver_0) || x[0].revents & IOPAUSE_READ) + sassserver_write_event(&a, x) ; + + for (ftrigio *p = ftrigio_head.next ; p != &ftrigio_head ; p = p->next) if (x[p->xindex].revents & IOPAUSE_READ) { - if (textmessage_handle(textmessage_receiver_0, &parse_protocol, 0) < 0) + if (!ftrigio_read(&a, p)) { - if (errno == EPIPE) break ; /* normal exit */ - cleanup() ; - strerr_diefu1sys(111, "handle messages from client") ; + p = p->prev ; + ftrigio_remove(p->next) ; } } + + r = sassserver_read_event(&a, x) ; } - cleanup() ; - return 0 ; + + cleanup(0) ; + _exit(0) ; } diff --git a/src/libs6/s6_compat_el_semicolon.c b/src/libs6/s6_compat_el_semicolon.c index fe4787e..8d214dd 100644 --- a/src/libs6/s6_compat_el_semicolon.c +++ b/src/libs6/s6_compat_el_semicolon.c @@ -25,30 +25,26 @@ static unsigned int el_getstrict (void) int s6_compat_el_semicolon (char const **argv) { static unsigned int nblock = 0 ; - int argc1 = 0 ; + unsigned int strict = el_getstrict() ; nblock++ ; - for (;; argc1++, argv++) + unsigned int i = 0 ; + for (; argv[i] ; i++) { - char const *arg = *argv ; - if (!arg) return argc1 + 1 ; - if (!arg[0]) return argc1 ; - else if (arg[0] == ' ') ++*argv ; - else + if (!argv[i][0]) return i ; + else if (argv[i][0] == ' ') argv[i]++ ; + else if (strict) { - unsigned int strict = el_getstrict() ; - if (strict) - { - char fmt1[UINT_FMT] ; - char fmt2[UINT_FMT] ; - fmt1[uint_fmt(fmt1, nblock)] = 0 ; - fmt2[uint_fmt(fmt2, (unsigned int)argc1)] = 0 ; - if (strict >= 2) - strerr_dief6x(100, "unquoted argument ", arg, " at block ", fmt1, " position ", fmt2) ; - else - strerr_warnw6x("unquoted argument ", arg, " at block ", fmt1, " position ", fmt2) ; - } + char fmt1[UINT_FMT] ; + char fmt2[UINT_FMT] ; + fmt1[uint_fmt(fmt1, nblock)] = 0 ; + fmt2[uint_fmt(fmt2, i)] = 0 ; + if (strict >= 2) + strerr_dief6x(100, "unquoted argument ", argv[i], " at block ", fmt1, " position ", fmt2) ; + else + strerr_warnw6x("unquoted argument ", argv[i], " at block ", fmt1, " position ", fmt2) ; } } + return i + 1 ; } #endif diff --git a/src/libs6/s6_supervise_link_names.c b/src/libs6/s6_supervise_link_names.c index de8e5c5..1002cc4 100644 --- a/src/libs6/s6_supervise_link_names.c +++ b/src/libs6/s6_supervise_link_names.c @@ -22,19 +22,19 @@ static inline void do_unlink (char const *scdir, char const *const *names, size_ s6_supervise_unlink(scdir, names[i], killopts) ; } -static uint16_t registerit (ftrigr_t *a, char *fn, size_t len, gid_t gid, uint32_t options, tain const *deadline, tain *stamp) +static int registerit (ftrigr *a, uint32_t *id, char *fn, size_t len, gid_t gid, uint32_t options, tain const *deadline, tain *stamp) { if (options & 4) { int fd ; memcpy(fn + len, "/down", 6) ; fd = open_trunc(fn) ; - if (fd < 0) return 0 ; + if (fd == -1) return 0 ; fd_close(fd) ; } memcpy(fn + len, "/" S6_SUPERVISE_EVENTDIR, 1 + sizeof(S6_SUPERVISE_EVENTDIR)) ; if (!ftrigw_fifodir_make(fn, gid, options & 1)) return 0 ; - return ftrigr_subscribe(a, fn, "s", 0, deadline, stamp) ; + return ftrigr_subscribe(a, id, 0, 0, fn, "s", deadline, stamp) ; } /* @@ -86,7 +86,7 @@ int s6_supervise_link_names (char const *scdir, char const *const *servicedirs, } { - ftrigr_t a = FTRIGR_ZERO ; + ftrigr a = FTRIGR_ZERO ; stralloc rpsa = STRALLOC_ZERO ; gid_t gid = options & 2 ? -1 : getegid() ; size_t scdirlen = strlen(scdir) ; @@ -94,7 +94,7 @@ int s6_supervise_link_names (char const *scdir, char const *const *servicedirs, size_t i = 0 ; uint32_t killopts = 0 ; int r ; - uint16_t ids[ntotal] ; + uint32_t ids[ntotal] ; char lname[scdirlen + maxnlen + 7] ; char fn[maxlen + 5 + (sizeof(S6_SUPERVISE_EVENTDIR) > 5 ? sizeof(S6_SUPERVISE_EVENTDIR) : 5)] ; if (!ftrigr_startf(&a, deadline, stamp)) return -1 ; @@ -108,13 +108,11 @@ int s6_supervise_link_names (char const *scdir, char const *const *servicedirs, memcpy(fn, servicedirs[i], len) ; if (!h) { - ids[m] = registerit(&a, fn, len, gid, options, deadline, stamp) ; - if (!ids[m++]) goto err ; + if (!registerit(&a, ids + m++, fn, len, gid, options, deadline, stamp)) goto err ; if (bitarray_peek(logged, i)) { memcpy(fn + len, "/log", 4) ; - ids[m] = registerit(&a, fn, len + 4, gid, options, deadline, stamp) ; - if (!ids[m++]) goto err ; + if (!registerit(&a, ids + m++, fn, len + 4, gid, options, deadline, stamp)) goto err ; } } fn[len] = 0 ; diff --git a/src/libs6/s6_supervise_unlink_names.c b/src/libs6/s6_supervise_unlink_names.c index a0b424d..d8bb4e0 100644 --- a/src/libs6/s6_supervise_unlink_names.c +++ b/src/libs6/s6_supervise_unlink_names.c @@ -12,10 +12,10 @@ #include #include -static uint16_t registerit (ftrigr_t *a, char *fn, size_t len, tain const *deadline, tain *stamp) +static int registerit (ftrigr *a, uint32_t *id, char *fn, size_t len, tain const *deadline, tain *stamp) { memcpy(fn + len, "/" S6_SUPERVISE_EVENTDIR, sizeof(S6_SUPERVISE_EVENTDIR) + 1) ; - return ftrigr_subscribe(a, fn, "x", 0, deadline, stamp) ; + return ftrigr_subscribe(a, id, 0, 0, fn, "x", deadline, stamp) ; } /* @@ -62,9 +62,9 @@ int s6_supervise_unlink_names (char const *scdir, char const *const *names, size } { - ftrigr_t a = FTRIGR_ZERO ; + ftrigr a = FTRIGR_ZERO ; unsigned int m = 0 ; - uint16_t ids[ntotal] ; + uint32_t ids[ntotal] ; if (options & 1 && !ftrigr_startf(&a, deadline, stamp)) return -1 ; for (size_t i = 0 ; i < n ; i++) { @@ -75,13 +75,11 @@ int s6_supervise_unlink_names (char const *scdir, char const *const *names, size memcpy(fn + scdirlen + 1, names[i], nlen) ; if (options & 1 && bitarray_peek(locked, i)) { - ids[m] = registerit(&a, fn, scdirlen + 1 + nlen, deadline, stamp) ; - if (ids[m]) m++ ; + if (registerit(&a, ids + m, fn, scdirlen + 1 + nlen, deadline, stamp)) m++ ; if (bitarray_peek(logged, i)) { memcpy(fn + scdirlen + 1 + nlen, "/log", 4) ; - ids[m] = registerit(&a, fn, scdirlen + 5 + nlen, deadline, stamp) ; - if (ids[m]) m++ ; + if (registerit(&a, ids + m, fn, scdirlen + 5 + nlen, deadline, stamp)) m++ ; } } fn[scdirlen + 1 + nlen] = 0 ; -- cgit v1.3.1 From 4cdcab0506e76666800d2bc111c602bb3154cc30 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Tue, 17 Mar 2026 16:00:25 +0000 Subject: s6-svscan trivial fix; s6-svunlink bugfix; start prep for 2.15.0.0 s6_supervise_unlink_names can spawn a s6-ftrigrd to wait for an 'x' event. This creates a fifodir under $scandir/$name/event. But after the unlink, $scandir/$name doesn't exist anymore, so s6-ftrigrd fails to clean it up. To fix that, we subscribe with the realpath of $scandir/$name instead. --- package/info | 2 +- src/libs6/s6_supervise_unlink_names.c | 14 ++++++++++---- src/supervision/s6-svscan.c | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) (limited to 'src/libs6') diff --git a/package/info b/package/info index 8c56c0c..edaa30f 100644 --- a/package/info +++ b/package/info @@ -1,4 +1,4 @@ package=s6 -version=2.14.0.1 +version=2.15.0.0 category=admin package_macro_name=S6 diff --git a/src/libs6/s6_supervise_unlink_names.c b/src/libs6/s6_supervise_unlink_names.c index d8bb4e0..a6c7be5 100644 --- a/src/libs6/s6_supervise_unlink_names.c +++ b/src/libs6/s6_supervise_unlink_names.c @@ -8,14 +8,18 @@ #include #include +#include +#include #include #include -static int registerit (ftrigr *a, uint32_t *id, char *fn, size_t len, tain const *deadline, tain *stamp) +static int registerit (ftrigr *a, uint32_t *id, char *fn, size_t len, stralloc *sa, tain const *deadline, tain *stamp) { memcpy(fn + len, "/" S6_SUPERVISE_EVENTDIR, sizeof(S6_SUPERVISE_EVENTDIR) + 1) ; - return ftrigr_subscribe(a, id, 0, 0, fn, "x", deadline, stamp) ; + sa->len = 0 ; + if (sarealpath(sa, fn) == -1) return 0 ; + return ftrigr_subscribe(a, id, 0, 0, sa->s, "x", deadline, stamp) ; } /* @@ -63,6 +67,7 @@ int s6_supervise_unlink_names (char const *scdir, char const *const *names, size { ftrigr a = FTRIGR_ZERO ; + stralloc sa = STRALLOC_ZERO ; unsigned int m = 0 ; uint32_t ids[ntotal] ; if (options & 1 && !ftrigr_startf(&a, deadline, stamp)) return -1 ; @@ -75,11 +80,11 @@ int s6_supervise_unlink_names (char const *scdir, char const *const *names, size memcpy(fn + scdirlen + 1, names[i], nlen) ; if (options & 1 && bitarray_peek(locked, i)) { - if (registerit(&a, ids + m, fn, scdirlen + 1 + nlen, deadline, stamp)) m++ ; + if (registerit(&a, ids + m, fn, scdirlen + 1 + nlen, &sa, deadline, stamp)) m++ ; if (bitarray_peek(logged, i)) { memcpy(fn + scdirlen + 1 + nlen, "/log", 4) ; - if (registerit(&a, ids + m, fn, scdirlen + 5 + nlen, deadline, stamp)) m++ ; + if (registerit(&a, ids + m, fn, scdirlen + 5 + nlen, &sa, deadline, stamp)) m++ ; } } fn[scdirlen + 1 + nlen] = 0 ; @@ -88,6 +93,7 @@ int s6_supervise_unlink_names (char const *scdir, char const *const *names, size s6_svc_writectl(scdir, S6_SVSCAN_CTLDIR, "an", 2) ; if (options & 1) { + stralloc_free(&sa) ; ftrigr_wait_and(&a, ids, m, deadline, stamp) ; ftrigr_end(&a) ; } diff --git a/src/supervision/s6-svscan.c b/src/supervision/s6-svscan.c index cf73c13..2f425a2 100644 --- a/src/supervision/s6-svscan.c +++ b/src/supervision/s6-svscan.c @@ -683,7 +683,7 @@ int main (int argc, char const *const *argv) PROG = "s6-svscan" ; golc = gol_main(argc, argv, 0, 0, rgola, GOLA_N, 0, wgola) ; argc -= golc ; argv += golc ; - if (argc < 2) dieusage() ; + if (!argc) dieusage() ; if (wgola[GOLA_MAX]) { if (!uint320_scan(wgola[GOLA_MAX], &max)) -- cgit v1.3.1 From 24637cd3776cda5fd0a919ba9343ba86d82d3e04 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Wed, 18 Mar 2026 01:57:01 +0000 Subject: More fixes, ftrigr_string addition, doc update --- INSTALL | 2 +- NEWS | 13 ++++ doc/index.html | 6 +- doc/libs6/ftrigr.html | 132 +++++++++++++++++-------------------- doc/libs6/s6-ftrigrd.html | 37 +++++------ doc/s6-setsid.html | 3 +- doc/upgrade.html | 17 +++++ package/deps.mak | 9 ++- src/include/s6/ftrigr.h | 13 ++-- src/libs6/deps-lib/s6 | 1 - src/libs6/ftrigr_peek.c | 7 +- src/libs6/ftrigr_peek1.c | 14 ---- src/libs6/ftrigr_wait_and.c | 4 +- src/libs6/ftrigr_wait_or.c | 5 +- src/pipe-tools/s6-ftrig-listen.c | 4 +- src/pipe-tools/s6-ftrig-listen1.c | 6 +- src/pipe-tools/s6-ftrig-wait.c | 6 +- src/supervision/s6-notifyoncheck.c | 6 +- src/supervision/s6_svlisten_loop.c | 13 ++-- 19 files changed, 151 insertions(+), 147 deletions(-) delete mode 100644 src/libs6/ftrigr_peek1.c (limited to 'src/libs6') diff --git a/INSTALL b/INSTALL index dd6bdaf..2cb405e 100644 --- a/INSTALL +++ b/INSTALL @@ -6,7 +6,7 @@ Build Instructions - A POSIX-compliant C development environment - GNU make version 3.81 or later - - skalibs version 2.14.5.1 or later: https://skarnet.org/software/skalibs/ + - skalibs version 2.14.6.0 or later: https://skarnet.org/software/skalibs/ - Recommended: execline version 2.9.8.1 or later: https://skarnet.org/software/execline/ (You can disable this requirement at configure time, but will lose some functionality.) diff --git a/NEWS b/NEWS index 061674f..a2f6592 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,18 @@ Changelog for s6. +In 2.15.0.0 +----------- + + - Bugfixes. + - s6-svscan's scandir argument is now mandatory. + - s6-setsid now autodetects its controlling terminal by default. + - Complete ftrigr refactor. This doesn't impact CLI programs, +except the next point. + - s6-ftrig-wait and s6-ftrig-listen1 now print the whole +sequence of events (followed by a newline) to stdout, rather than +just the triggering event. + + In 2.14.0.1 ----------- diff --git a/doc/index.html b/doc/index.html index 1baa6ab..925661e 100644 --- a/doc/index.html +++ b/doc/index.html @@ -83,7 +83,7 @@ with s6
  • A POSIX-compliant system with a standard C development environment
  • GNU make, version 3.81 or later
  • skalibs version -2.14.5.1 or later. It's a build-time requirement. It's also a run-time +2.14.6.0 or later. It's a build-time requirement. It's also a run-time requirement if you link against the shared version of the skalibs library.
  • (Optional, but really recommended for full functionality): @@ -115,8 +115,8 @@ want nsswitch-like functionality:

    Download

      -
    • The current released version of s6 is 2.14.0.1. -You can access its checksum here.
    • +
    • The current released version of s6 is 2.15.0.0. +You can access its checksum here.
    • Alternatively, you can checkout a copy of the s6 git repository: diff --git a/doc/libs6/ftrigr.html b/doc/libs6/ftrigr.html index 052d7bf..a8cf98b 100644 --- a/doc/libs6/ftrigr.html +++ b/doc/libs6/ftrigr.html @@ -43,11 +43,6 @@ and to always use wait_nohang() to reap children, simply ignoring pids you don't know.

      -

      - If your application has trouble handling unknown -children, consider using an ftrigrd service. (And fix your application!) -

      -

      A programming example

      @@ -61,8 +56,8 @@ for instance, illustrate how to use the ftrigr library.

        -
      • Synchronous functions take a tain_t const * -(deadline) parameter and a tain_t * (stamp) +
      • Synchronous functions take a tain const * +(deadline) parameter and a tain * (stamp) parameter. Those are pointers to tain_t structures containing absolute times; the former represents a deadline (in most cases, this time will be in the future) and the latter must be an accurate enough timestamp. These @@ -100,28 +95,25 @@ control on.
      • Starting and ending a session

        -ftrigr_t a = FTRIGR_ZERO ;
        +ftrigr a = FTRIGR_ZERO ;
         tain_t deadline, stamp ;
         
         tain_now(&stamp) ;
         tain_addsec(&deadline, &stamp, 2)
         
        -// char const *path = FTRIGR_IPCPATH ;
        -// ftrigr_start(&a, path, &deadline, &stamp) ;
         ftrigr_startf(&a, &deadline, &stamp) ;
         

        -ftrigr_start starts a session with an ftrigrd service listening on -path.
        ftrigr_startf starts a session with an ftrigrd process as a child (which is the simplest usage).
        -a is an ftrigr_t structure that must be declared in the stack and -initialized to FTRIGR_ZERO. +a is an ftrigr structure that can be declared in the stack and +must be initialized to FTRIGR_ZERO. stamp must be an accurate enough timestamp.
        If the session initialization fails, the function returns 0 and errno is set; else the function returns 1.

        +

        If the absolute time deadline is reached and the function has not returned yet, it immediately returns 0 with errno set to ETIMEDOUT. @@ -135,8 +127,8 @@ problem with the underlying processes.

        You can have more than one session open in parallel, by declaring -several distinct ftrigr_t structures and calling -ftrigr_startf (or ftrigr_start) more than once. +several distinct ftrigr structures and calling +ftrigr_startf more than once. However, this is useless, since one single session can handle virtually as many concurrent fifodirs as your application needs.

        @@ -156,8 +148,10 @@ ftrigr_end(&a) ; char const *path = "/var/lib/myservice/fifodir" ; char const *re = "a.*b|c*d" ; uint32_t options = 0 ; +uint32_t timeout = 60000 ; +uint32_t id ; -uint16_t id = ftrigr_subscribe (&a, path, re, options, &deadline, &stamp) ; +int r = ftrigr_subscribe(&a, &id, options, timeout, path, re, options, &deadline, &stamp) ;

        @@ -165,7 +159,9 @@ uint16_t id = ftrigr_subscribe (&a, path, re, options, &deadline, &s s6-ftrigrd daemon, related to the open session represented by the a structure, to subscribe to the path fifodir, and to notify the application when it receives -a series of events that matches the re regexp. +a series of events that matches the re regexp.

        + +

        options can be 0 or FTRIGR_REPEAT. If it is 0, the daemon will automatically unsubscribe from path once re has been matched by a series of events. If it is FTRIGR_REPEAT, it will remain @@ -173,8 +169,16 @@ subscribed until told otherwise.

        - ftrigr_subscribe() returns 0 and sets errno in case of failure, or -a nonzero 16-bit number identifying the subscription in case of success. + If timeout is nonzero, it represents a number of milliseconds; +after this delay, the daemon will automatically unsubscribe from +path and report an ETIMEDOUT error to the client. It is not +advised to use a nonzero timeout along with the FTRIGR_REPEAT option. +

        + +

        + If it fails, ftrigr_subscribe() returns 0 and sets errno. If +it succeeds, it returns 1 and stores a number identifying the subscription +into id.

        @@ -188,26 +192,29 @@ and events can be sent without the risk of a race condition.

        Synchronously waiting for events

        -uint16_t list[1] ;
        +uint32_t list[1] = { id } ;
         unsigned int n = 1 ;
        -char trigger ;
        -list[0] = id ;
        +ftrigr_string fs ;
         
         // r = ftrigr_wait_and(&a, list, n, &deadline, &stamp) ;
        -r = ftrigr_wait_or(&a, list, n, &deadline, &stamp, &trigger) ;
        +r = ftrigr_wait_or(&a, list, n, &deadline, &stamp, &fs) ;
         

        ftrigr_wait_and() waits for all the n fifodirs whose ids are listed in list to receive an event. It returns -1 -in case of error or timeout, or a non-negative integer in case of success.
        +in case of error or timeout, or a non-negative integer in case of success. +

        + +

        ftrigr_wait_or() waits for one of the n fifodirs whose ids are listed in list to receive an event. It returns -1 in case of error or timeout; if it succeeds, the return value is the position in list, starting at 0, of the identifier that received -an event; and trigger is set to the character that triggered that -event, i.e. the last character of a sequence that matched the regular -expression re used in the subscription. +an event; and fs is the list of events that were received +since the subscription and matched the re regular expression. +fs.s is a char * pointing to the (not null-terminated) +string of events, and fs.len is its length.

        Asynchronously waiting for events

        @@ -218,7 +225,7 @@ of usage examples.)

        -int ftrigr_fd (ftrigr_t const *a)
        +int ftrigr_fd (ftrigr const *a)
         

        @@ -227,30 +234,19 @@ int ftrigr_fd (ftrigr_t const *a)

        -int ftrigr_updateb (ftrigr_t *a)
        +int ftrigr_update (ftrigr *a)
         

        Call this function whenever the fd checks readability: it will update a's internal structures with information from the -s6-ftrigrd daemon. It returns -1 if an error -occurs; in case of success, it returns the number of identifiers for -which something happened. -

        - -

        - When ftrigr_updateb returns, -genalloc_s(uint16_t, &a->list) points to an array of -genalloc_len(uint16_t, &a->list) 16-bit unsigned -integers. Those integers are ids waiting to be passed to -ftrigr_check or ftrigr_checksa. -The number of ids already acknowledged is stored in -a->head, so the first unacknowledged id is -genalloc_s(uint16_t, &a->list)[a->head]. +s6-ftrigrd daemon. It returns -1 (and sets +errno) if an error occurs, 0 if there were no events, and 1 if events +were received.

        -int ftrigr_check (ftrigr_t *a, uint16_t id, char *what)
        +int ftrigr_peek (ftrigr *a, uint32_t id, ftrigr_string *fs)
         

        @@ -263,49 +259,39 @@ call to ftrigr_updateb(). number may have been transmitted from s6-ftrigrd.

      • If no notification happened yet, returns 0.
      • -
      • If something happened, writes the character that triggered the -latest notification into what and returns the number of -times that an event happened to this identifier since the last -call to ftrigr_check().
      • +
      • If something happened, returns 1, and fs contains +the string of events that were received since the subscription or +since the last call to ftrigr_ack (see below). +fs->s is a pointer to the non-null-terminated string, +and fs->len is its length.
      -int ftrigr_checksa (ftrigr_t *a, uint16_t id, stralloc *what)
      +void ftrigr_ack (ftrigr *a, uint32_t id)
       

      - Checks whether an event happened to id. Use after a -call to ftrigr_update(), as an alternative to ftrigr_check(). + Resets the stored string of events. The next invocation of +ftrigr_peek() will only show new events, if any.

      -
        -
      • If an error occurred, returns -1 and sets errno. The error -number may have been transmitted from -s6-ftrigrd.
      • -
      • If no notification happened yet, returns 0.
      • -
      • If something happened, appends one character to the end of the what -stralloc -for every time a notification was triggered since the last call -to ftrigr_check(). Each character is the one that triggered -a notification. The function then returns 1.
      • -
      -
      -void ftrigr_ack (ftrigr_t *a, size_t n)
      +int ftrigr_release (ftrigr *a, uint32_t id)
       

      - Acknowledges reading n ids from the id list updated by -ftrigr_updateb. + Frees the resources used by subscription id. Use this +after getting an event from a subscription done without the +FTRIGR_REPEAT flag and reading its results, if you want to +keep the session open and perform more subscriptions.

      -
      -int ftrigr_update (ftrigr_t *a)
      -
      -

      - Acknowledges all the pending ids (i.e. clears the stored id list) -then calls ftrigr_updateb(). + If subscription id was given the FTRIGR_REPEAT flag, +use ftrigr_unsubscribe() instead. If you're not going +to perform other subscriptions, ftrigr_end() will +free all the resources without you needing to call +ftrigr_release() first.

      diff --git a/doc/libs6/s6-ftrigrd.html b/doc/libs6/s6-ftrigrd.html index 7325c72..672b660 100644 --- a/doc/libs6/s6-ftrigrd.html +++ b/doc/libs6/s6-ftrigrd.html @@ -17,7 +17,7 @@ skarnet.org

      -

      The s6-ftrigrd program

      +

      The s6-ftrigrd internal program

      s6-ftrigrd is a helper program that manages a set of subscriptions to fifodirs as well @@ -29,24 +29,17 @@ events happen.

      Interface

      - s6-ftrigrd is not meant to be called directly. -

      - -
        -
      • If the client program uses ftrigr_startf(), it spawns an instance of + s6-ftrigrd is not meant to be called directly. When the client calls +ftrigr_start() or ftrigr_startf, it spawns an instance of s6-ftrigrd as a child. s6-ftrigrd's stdin is a pipe reading from the client; its stdout is a pipe writing to the client; its stderr is the same as the client's; and there's an additional pipe from s6-ftrigrd to the client, used for asynchronous -notifications.
      • -
      • If the client program uses ftrigr_start(), then it tries to connect -to a Unix domain socket. An ftrigrd local service should be listening to that -socket, i.e. a Unix domain super-server such as -s6-ipcserver -spawning an s6-ftrigrd program on every connection. Then an s6-ftrigrd instance is created -for the client.
      • -
      • When the client uses ftrigr_end(), or closes s6-ftrigrd's stdin in -any way, s6-ftrigrd exits 0.
      • -
      +notifications. +

      + +

      When the client uses ftrigr_end(), or closes s6-ftrigrd's stdin in +any way, s6-ftrigrd exits 0. +

      s6-ftrigrd handles the grunt work of creating fifos in a @@ -60,7 +53,7 @@ the client.

      The connection management between the client and s6-ftrigrd is entirely done -by the textclient library from skalibs. +by the sassclient library from skalibs.

      @@ -71,9 +64,13 @@ to read them. To avoid uncontrolled growth, make sure your client calls

      - An s6-ftrigrd instance can only handle up to FTRIGRD_MAX (defined in s6/ftrigr.h) -subscriptions at once. By default, this number is 1000, which is more than enough for -any reasonable system. + The number of concurrent subscriptions that an s6-ftrigrd instance can handle is +only limited by RAM and open file descriptors. It is likely that the latter is the +bottleneck: s6-ftrigrd uses two file descriptors per fifodir. With a default +limit of 1024 open file descriptors per process, it means that s6-ftrigrd can +handle around 500 concurrent fifodirs, which is reasonable for most systems, but +make sure to increase the open files resource limit before starting an ftrigr +session if you need more.

      diff --git a/doc/s6-setsid.html b/doc/s6-setsid.html index 2a9e3d3..af10a57 100644 --- a/doc/s6-setsid.html +++ b/doc/s6-setsid.html @@ -69,7 +69,8 @@ message; it will exec into prog even if it cannot perform the operations.
    • -d ctty : assume file descriptor number ctty is -the controlling terminal for the current session. Default is 0. +the controlling terminal for the current session. (By default, the +value is obtained from /dev/tty.) This is only useful when used with the -f or -g options.
    diff --git a/doc/upgrade.html b/doc/upgrade.html index ce8d682..8ae86f5 100644 --- a/doc/upgrade.html +++ b/doc/upgrade.html @@ -18,6 +18,23 @@

    What has changed in s6

    +

    in 2.15.0.0

    + +
      +
    • skalibs +dependency bumped to 2.14.6.0
    • +
    • Large changes around the ftrigr library: +
        +
      • s6-ftrigrd is now an +internal program
      • +
      • Local ftrigrd services are not supported anymore, +s6-ftrigrd now always runs as a child of the client
      • +
      • The API of the ftrigr library +is somewhat different.
      • . +
    • +
    + +

    in 2.14.0.1

      diff --git a/package/deps.mak b/package/deps.mak index b70c0aa..b6bae62 100644 --- a/package/deps.mak +++ b/package/deps.mak @@ -52,7 +52,6 @@ src/instance/s6-instance-status.o src/instance/s6-instance-status.lo: src/instan src/libs6/ftrigr_ack.o src/libs6/ftrigr_ack.lo: src/libs6/ftrigr_ack.c src/libs6/ftrigr-internal.h src/include/s6/ftrigr.h src/libs6/ftrigr_end.o src/libs6/ftrigr_end.lo: src/libs6/ftrigr_end.c src/libs6/ftrigr-internal.h src/include/s6/ftrigr.h src/libs6/ftrigr_peek.o src/libs6/ftrigr_peek.lo: src/libs6/ftrigr_peek.c src/libs6/ftrigr-internal.h src/include/s6/ftrigr.h -src/libs6/ftrigr_peek1.o src/libs6/ftrigr_peek1.lo: src/libs6/ftrigr_peek1.c src/include/s6/ftrigr.h src/libs6/ftrigr_release.o src/libs6/ftrigr_release.lo: src/libs6/ftrigr_release.c src/libs6/ftrigr-internal.h src/include/s6/ftrigr.h src/libs6/ftrigr_start.o src/libs6/ftrigr_start.lo: src/libs6/ftrigr_start.c src/include/s6/ftrigr.h src/libs6/ftrigr_startf.o src/libs6/ftrigr_startf.lo: src/libs6/ftrigr_startf.c src/libs6/ftrigr-internal.h src/include/s6/config.h src/include/s6/ftrigr.h @@ -229,15 +228,15 @@ s6-instance-maker: src/instance/s6-instance-maker.o libs6auto.a.xyzzy -lskarnet s6-instance-status: EXTRA_LIBS := s6-instance-status: src/instance/s6-instance-status.o -lskarnet ifeq ($(strip $(STATIC_LIBS_ARE_PIC)),) -libs6.a.xyzzy: src/libs6/ftrigr_ack.o src/libs6/ftrigr_end.o src/libs6/ftrigr_peek.o src/libs6/ftrigr_peek1.o src/libs6/ftrigr_release.o src/libs6/ftrigr_start.o src/libs6/ftrigr_startf.o src/libs6/ftrigr_subscribe.o src/libs6/ftrigr_unsubscribe.o src/libs6/ftrigr_update.o src/libs6/ftrigr_wait_and.o src/libs6/ftrigr_wait_or.o src/libs6/ftrigw_clean.o src/libs6/ftrigw_fifodir_make.o src/libs6/ftrigw_notify.o src/libs6/ftrigw_notifyb.o src/libs6/ftrigw_notifyb_nosig.o src/libs6/s6_accessrules_backend_cdb.o src/libs6/s6_accessrules_backend_fs.o src/libs6/s6_accessrules_keycheck_ip4.o src/libs6/s6_accessrules_keycheck_ip6.o src/libs6/s6_accessrules_keycheck_reversedns.o src/libs6/s6_accessrules_keycheck_uidgid.o src/libs6/s6_accessrules_params_free.o src/libs6/s6_accessrules_uidgid_cdb.o src/libs6/s6_accessrules_uidgid_fs.o src/libs6/s6_compat_el_semicolon.o src/libs6/s6_dtally_pack.o src/libs6/s6_dtally_unpack.o src/libs6/s6_dtally_read.o src/libs6/s6_dtally_write.o src/libs6/s6_instance_chdirservice.o src/libs6/s6_servicedir_file_list.o src/libs6/s6_servicedir_instances_recreate_offline.o src/libs6/s6_servicedir_instances_recreate_offline_tmp.o src/libs6/s6_svc_ok.o src/libs6/s6_svc_write.o src/libs6/s6_svc_writectl.o src/libs6/s6_svstatus_pack.o src/libs6/s6_svstatus_read.o src/libs6/s6_svstatus_unpack.o src/libs6/s6_svstatus_write.o src/libs6/s6_fdholder_delete.o src/libs6/s6_fdholder_delete_async.o src/libs6/s6_fdholder_end.o src/libs6/s6_fdholder_getdump.o src/libs6/s6_fdholder_list.o src/libs6/s6_fdholder_list_async.o src/libs6/s6_fdholder_list_cb.o src/libs6/s6_fdholder_retrieve.o src/libs6/s6_fdholder_retrieve_async.o src/libs6/s6_fdholder_retrieve_cb.o src/libs6/s6_fdholder_setdump.o src/libs6/s6_fdholder_start.o src/libs6/s6_fdholder_store.o src/libs6/s6_fdholder_store_async.o src/libs6/s6_supervise_link.o src/libs6/s6_supervise_link_names.o src/libs6/s6_supervise_unlink.o src/libs6/s6_supervise_unlink_names.o +libs6.a.xyzzy: src/libs6/ftrigr_ack.o src/libs6/ftrigr_end.o src/libs6/ftrigr_peek.o src/libs6/ftrigr_release.o src/libs6/ftrigr_start.o src/libs6/ftrigr_startf.o src/libs6/ftrigr_subscribe.o src/libs6/ftrigr_unsubscribe.o src/libs6/ftrigr_update.o src/libs6/ftrigr_wait_and.o src/libs6/ftrigr_wait_or.o src/libs6/ftrigw_clean.o src/libs6/ftrigw_fifodir_make.o src/libs6/ftrigw_notify.o src/libs6/ftrigw_notifyb.o src/libs6/ftrigw_notifyb_nosig.o src/libs6/s6_accessrules_backend_cdb.o src/libs6/s6_accessrules_backend_fs.o src/libs6/s6_accessrules_keycheck_ip4.o src/libs6/s6_accessrules_keycheck_ip6.o src/libs6/s6_accessrules_keycheck_reversedns.o src/libs6/s6_accessrules_keycheck_uidgid.o src/libs6/s6_accessrules_params_free.o src/libs6/s6_accessrules_uidgid_cdb.o src/libs6/s6_accessrules_uidgid_fs.o src/libs6/s6_compat_el_semicolon.o src/libs6/s6_dtally_pack.o src/libs6/s6_dtally_unpack.o src/libs6/s6_dtally_read.o src/libs6/s6_dtally_write.o src/libs6/s6_instance_chdirservice.o src/libs6/s6_servicedir_file_list.o src/libs6/s6_servicedir_instances_recreate_offline.o src/libs6/s6_servicedir_instances_recreate_offline_tmp.o src/libs6/s6_svc_ok.o src/libs6/s6_svc_write.o src/libs6/s6_svc_writectl.o src/libs6/s6_svstatus_pack.o src/libs6/s6_svstatus_read.o src/libs6/s6_svstatus_unpack.o src/libs6/s6_svstatus_write.o src/libs6/s6_fdholder_delete.o src/libs6/s6_fdholder_delete_async.o src/libs6/s6_fdholder_end.o src/libs6/s6_fdholder_getdump.o src/libs6/s6_fdholder_list.o src/libs6/s6_fdholder_list_async.o src/libs6/s6_fdholder_list_cb.o src/libs6/s6_fdholder_retrieve.o src/libs6/s6_fdholder_retrieve_async.o src/libs6/s6_fdholder_retrieve_cb.o src/libs6/s6_fdholder_setdump.o src/libs6/s6_fdholder_start.o src/libs6/s6_fdholder_store.o src/libs6/s6_fdholder_store_async.o src/libs6/s6_supervise_link.o src/libs6/s6_supervise_link_names.o src/libs6/s6_supervise_unlink.o src/libs6/s6_supervise_unlink_names.o else -libs6.a.xyzzy:src/libs6/ftrigr_ack.lo src/libs6/ftrigr_end.lo src/libs6/ftrigr_peek.lo src/libs6/ftrigr_peek1.lo src/libs6/ftrigr_release.lo src/libs6/ftrigr_start.lo src/libs6/ftrigr_startf.lo src/libs6/ftrigr_subscribe.lo src/libs6/ftrigr_unsubscribe.lo src/libs6/ftrigr_update.lo src/libs6/ftrigr_wait_and.lo src/libs6/ftrigr_wait_or.lo src/libs6/ftrigw_clean.lo src/libs6/ftrigw_fifodir_make.lo src/libs6/ftrigw_notify.lo src/libs6/ftrigw_notifyb.lo src/libs6/ftrigw_notifyb_nosig.lo src/libs6/s6_accessrules_backend_cdb.lo src/libs6/s6_accessrules_backend_fs.lo src/libs6/s6_accessrules_keycheck_ip4.lo src/libs6/s6_accessrules_keycheck_ip6.lo src/libs6/s6_accessrules_keycheck_reversedns.lo src/libs6/s6_accessrules_keycheck_uidgid.lo src/libs6/s6_accessrules_params_free.lo src/libs6/s6_accessrules_uidgid_cdb.lo src/libs6/s6_accessrules_uidgid_fs.lo src/libs6/s6_compat_el_semicolon.lo src/libs6/s6_dtally_pack.lo src/libs6/s6_dtally_unpack.lo src/libs6/s6_dtally_read.lo src/libs6/s6_dtally_write.lo src/libs6/s6_instance_chdirservice.lo src/libs6/s6_servicedir_file_list.lo src/libs6/s6_servicedir_instances_recreate_offline.lo src/libs6/s6_servicedir_instances_recreate_offline_tmp.lo src/libs6/s6_svc_ok.lo src/libs6/s6_svc_write.lo src/libs6/s6_svc_writectl.lo src/libs6/s6_svstatus_pack.lo src/libs6/s6_svstatus_read.lo src/libs6/s6_svstatus_unpack.lo src/libs6/s6_svstatus_write.lo src/libs6/s6_fdholder_delete.lo src/libs6/s6_fdholder_delete_async.lo src/libs6/s6_fdholder_end.lo src/libs6/s6_fdholder_getdump.lo src/libs6/s6_fdholder_list.lo src/libs6/s6_fdholder_list_async.lo src/libs6/s6_fdholder_list_cb.lo src/libs6/s6_fdholder_retrieve.lo src/libs6/s6_fdholder_retrieve_async.lo src/libs6/s6_fdholder_retrieve_cb.lo src/libs6/s6_fdholder_setdump.lo src/libs6/s6_fdholder_start.lo src/libs6/s6_fdholder_store.lo src/libs6/s6_fdholder_store_async.lo src/libs6/s6_supervise_link.lo src/libs6/s6_supervise_link_names.lo src/libs6/s6_supervise_unlink.lo src/libs6/s6_supervise_unlink_names.lo +libs6.a.xyzzy:src/libs6/ftrigr_ack.lo src/libs6/ftrigr_end.lo src/libs6/ftrigr_peek.lo src/libs6/ftrigr_release.lo src/libs6/ftrigr_start.lo src/libs6/ftrigr_startf.lo src/libs6/ftrigr_subscribe.lo src/libs6/ftrigr_unsubscribe.lo src/libs6/ftrigr_update.lo src/libs6/ftrigr_wait_and.lo src/libs6/ftrigr_wait_or.lo src/libs6/ftrigw_clean.lo src/libs6/ftrigw_fifodir_make.lo src/libs6/ftrigw_notify.lo src/libs6/ftrigw_notifyb.lo src/libs6/ftrigw_notifyb_nosig.lo src/libs6/s6_accessrules_backend_cdb.lo src/libs6/s6_accessrules_backend_fs.lo src/libs6/s6_accessrules_keycheck_ip4.lo src/libs6/s6_accessrules_keycheck_ip6.lo src/libs6/s6_accessrules_keycheck_reversedns.lo src/libs6/s6_accessrules_keycheck_uidgid.lo src/libs6/s6_accessrules_params_free.lo src/libs6/s6_accessrules_uidgid_cdb.lo src/libs6/s6_accessrules_uidgid_fs.lo src/libs6/s6_compat_el_semicolon.lo src/libs6/s6_dtally_pack.lo src/libs6/s6_dtally_unpack.lo src/libs6/s6_dtally_read.lo src/libs6/s6_dtally_write.lo src/libs6/s6_instance_chdirservice.lo src/libs6/s6_servicedir_file_list.lo src/libs6/s6_servicedir_instances_recreate_offline.lo src/libs6/s6_servicedir_instances_recreate_offline_tmp.lo src/libs6/s6_svc_ok.lo src/libs6/s6_svc_write.lo src/libs6/s6_svc_writectl.lo src/libs6/s6_svstatus_pack.lo src/libs6/s6_svstatus_read.lo src/libs6/s6_svstatus_unpack.lo src/libs6/s6_svstatus_write.lo src/libs6/s6_fdholder_delete.lo src/libs6/s6_fdholder_delete_async.lo src/libs6/s6_fdholder_end.lo src/libs6/s6_fdholder_getdump.lo src/libs6/s6_fdholder_list.lo src/libs6/s6_fdholder_list_async.lo src/libs6/s6_fdholder_list_cb.lo src/libs6/s6_fdholder_retrieve.lo src/libs6/s6_fdholder_retrieve_async.lo src/libs6/s6_fdholder_retrieve_cb.lo src/libs6/s6_fdholder_setdump.lo src/libs6/s6_fdholder_start.lo src/libs6/s6_fdholder_store.lo src/libs6/s6_fdholder_store_async.lo src/libs6/s6_supervise_link.lo src/libs6/s6_supervise_link_names.lo src/libs6/s6_supervise_unlink.lo src/libs6/s6_supervise_unlink_names.lo endif libs6.pc: EXTRA_LIBS := -lskarnet libs6.so.xyzzy: EXTRA_LIBS := -lskarnet -libs6.so.xyzzy:src/libs6/ftrigr_ack.lo src/libs6/ftrigr_end.lo src/libs6/ftrigr_peek.lo src/libs6/ftrigr_peek1.lo src/libs6/ftrigr_release.lo src/libs6/ftrigr_start.lo src/libs6/ftrigr_startf.lo src/libs6/ftrigr_subscribe.lo src/libs6/ftrigr_unsubscribe.lo src/libs6/ftrigr_update.lo src/libs6/ftrigr_wait_and.lo src/libs6/ftrigr_wait_or.lo src/libs6/ftrigw_clean.lo src/libs6/ftrigw_fifodir_make.lo src/libs6/ftrigw_notify.lo src/libs6/ftrigw_notifyb.lo src/libs6/ftrigw_notifyb_nosig.lo src/libs6/s6_accessrules_backend_cdb.lo src/libs6/s6_accessrules_backend_fs.lo src/libs6/s6_accessrules_keycheck_ip4.lo src/libs6/s6_accessrules_keycheck_ip6.lo src/libs6/s6_accessrules_keycheck_reversedns.lo src/libs6/s6_accessrules_keycheck_uidgid.lo src/libs6/s6_accessrules_params_free.lo src/libs6/s6_accessrules_uidgid_cdb.lo src/libs6/s6_accessrules_uidgid_fs.lo src/libs6/s6_compat_el_semicolon.lo src/libs6/s6_dtally_pack.lo src/libs6/s6_dtally_unpack.lo src/libs6/s6_dtally_read.lo src/libs6/s6_dtally_write.lo src/libs6/s6_instance_chdirservice.lo src/libs6/s6_servicedir_file_list.lo src/libs6/s6_servicedir_instances_recreate_offline.lo src/libs6/s6_servicedir_instances_recreate_offline_tmp.lo src/libs6/s6_svc_ok.lo src/libs6/s6_svc_write.lo src/libs6/s6_svc_writectl.lo src/libs6/s6_svstatus_pack.lo src/libs6/s6_svstatus_read.lo src/libs6/s6_svstatus_unpack.lo src/libs6/s6_svstatus_write.lo src/libs6/s6_fdholder_delete.lo src/libs6/s6_fdholder_delete_async.lo src/libs6/s6_fdholder_end.lo src/libs6/s6_fdholder_getdump.lo src/libs6/s6_fdholder_list.lo src/libs6/s6_fdholder_list_async.lo src/libs6/s6_fdholder_list_cb.lo src/libs6/s6_fdholder_retrieve.lo src/libs6/s6_fdholder_retrieve_async.lo src/libs6/s6_fdholder_retrieve_cb.lo src/libs6/s6_fdholder_setdump.lo src/libs6/s6_fdholder_start.lo src/libs6/s6_fdholder_store.lo src/libs6/s6_fdholder_store_async.lo src/libs6/s6_supervise_link.lo src/libs6/s6_supervise_link_names.lo src/libs6/s6_supervise_unlink.lo src/libs6/s6_supervise_unlink_names.lo +libs6.so.xyzzy:src/libs6/ftrigr_ack.lo src/libs6/ftrigr_end.lo src/libs6/ftrigr_peek.lo src/libs6/ftrigr_release.lo src/libs6/ftrigr_start.lo src/libs6/ftrigr_startf.lo src/libs6/ftrigr_subscribe.lo src/libs6/ftrigr_unsubscribe.lo src/libs6/ftrigr_update.lo src/libs6/ftrigr_wait_and.lo src/libs6/ftrigr_wait_or.lo src/libs6/ftrigw_clean.lo src/libs6/ftrigw_fifodir_make.lo src/libs6/ftrigw_notify.lo src/libs6/ftrigw_notifyb.lo src/libs6/ftrigw_notifyb_nosig.lo src/libs6/s6_accessrules_backend_cdb.lo src/libs6/s6_accessrules_backend_fs.lo src/libs6/s6_accessrules_keycheck_ip4.lo src/libs6/s6_accessrules_keycheck_ip6.lo src/libs6/s6_accessrules_keycheck_reversedns.lo src/libs6/s6_accessrules_keycheck_uidgid.lo src/libs6/s6_accessrules_params_free.lo src/libs6/s6_accessrules_uidgid_cdb.lo src/libs6/s6_accessrules_uidgid_fs.lo src/libs6/s6_compat_el_semicolon.lo src/libs6/s6_dtally_pack.lo src/libs6/s6_dtally_unpack.lo src/libs6/s6_dtally_read.lo src/libs6/s6_dtally_write.lo src/libs6/s6_instance_chdirservice.lo src/libs6/s6_servicedir_file_list.lo src/libs6/s6_servicedir_instances_recreate_offline.lo src/libs6/s6_servicedir_instances_recreate_offline_tmp.lo src/libs6/s6_svc_ok.lo src/libs6/s6_svc_write.lo src/libs6/s6_svc_writectl.lo src/libs6/s6_svstatus_pack.lo src/libs6/s6_svstatus_read.lo src/libs6/s6_svstatus_unpack.lo src/libs6/s6_svstatus_write.lo src/libs6/s6_fdholder_delete.lo src/libs6/s6_fdholder_delete_async.lo src/libs6/s6_fdholder_end.lo src/libs6/s6_fdholder_getdump.lo src/libs6/s6_fdholder_list.lo src/libs6/s6_fdholder_list_async.lo src/libs6/s6_fdholder_list_cb.lo src/libs6/s6_fdholder_retrieve.lo src/libs6/s6_fdholder_retrieve_async.lo src/libs6/s6_fdholder_retrieve_cb.lo src/libs6/s6_fdholder_setdump.lo src/libs6/s6_fdholder_start.lo src/libs6/s6_fdholder_store.lo src/libs6/s6_fdholder_store_async.lo src/libs6/s6_supervise_link.lo src/libs6/s6_supervise_link_names.lo src/libs6/s6_supervise_unlink.lo src/libs6/s6_supervise_unlink_names.lo libs6.dylib.xyzzy: EXTRA_LIBS := -lskarnet -libs6.dylib.xyzzy:src/libs6/ftrigr_ack.lo src/libs6/ftrigr_end.lo src/libs6/ftrigr_peek.lo src/libs6/ftrigr_peek1.lo src/libs6/ftrigr_release.lo src/libs6/ftrigr_start.lo src/libs6/ftrigr_startf.lo src/libs6/ftrigr_subscribe.lo src/libs6/ftrigr_unsubscribe.lo src/libs6/ftrigr_update.lo src/libs6/ftrigr_wait_and.lo src/libs6/ftrigr_wait_or.lo src/libs6/ftrigw_clean.lo src/libs6/ftrigw_fifodir_make.lo src/libs6/ftrigw_notify.lo src/libs6/ftrigw_notifyb.lo src/libs6/ftrigw_notifyb_nosig.lo src/libs6/s6_accessrules_backend_cdb.lo src/libs6/s6_accessrules_backend_fs.lo src/libs6/s6_accessrules_keycheck_ip4.lo src/libs6/s6_accessrules_keycheck_ip6.lo src/libs6/s6_accessrules_keycheck_reversedns.lo src/libs6/s6_accessrules_keycheck_uidgid.lo src/libs6/s6_accessrules_params_free.lo src/libs6/s6_accessrules_uidgid_cdb.lo src/libs6/s6_accessrules_uidgid_fs.lo src/libs6/s6_compat_el_semicolon.lo src/libs6/s6_dtally_pack.lo src/libs6/s6_dtally_unpack.lo src/libs6/s6_dtally_read.lo src/libs6/s6_dtally_write.lo src/libs6/s6_instance_chdirservice.lo src/libs6/s6_servicedir_file_list.lo src/libs6/s6_servicedir_instances_recreate_offline.lo src/libs6/s6_servicedir_instances_recreate_offline_tmp.lo src/libs6/s6_svc_ok.lo src/libs6/s6_svc_write.lo src/libs6/s6_svc_writectl.lo src/libs6/s6_svstatus_pack.lo src/libs6/s6_svstatus_read.lo src/libs6/s6_svstatus_unpack.lo src/libs6/s6_svstatus_write.lo src/libs6/s6_fdholder_delete.lo src/libs6/s6_fdholder_delete_async.lo src/libs6/s6_fdholder_end.lo src/libs6/s6_fdholder_getdump.lo src/libs6/s6_fdholder_list.lo src/libs6/s6_fdholder_list_async.lo src/libs6/s6_fdholder_list_cb.lo src/libs6/s6_fdholder_retrieve.lo src/libs6/s6_fdholder_retrieve_async.lo src/libs6/s6_fdholder_retrieve_cb.lo src/libs6/s6_fdholder_setdump.lo src/libs6/s6_fdholder_start.lo src/libs6/s6_fdholder_store.lo src/libs6/s6_fdholder_store_async.lo src/libs6/s6_supervise_link.lo src/libs6/s6_supervise_link_names.lo src/libs6/s6_supervise_unlink.lo src/libs6/s6_supervise_unlink_names.lo +libs6.dylib.xyzzy:src/libs6/ftrigr_ack.lo src/libs6/ftrigr_end.lo src/libs6/ftrigr_peek.lo src/libs6/ftrigr_release.lo src/libs6/ftrigr_start.lo src/libs6/ftrigr_startf.lo src/libs6/ftrigr_subscribe.lo src/libs6/ftrigr_unsubscribe.lo src/libs6/ftrigr_update.lo src/libs6/ftrigr_wait_and.lo src/libs6/ftrigr_wait_or.lo src/libs6/ftrigw_clean.lo src/libs6/ftrigw_fifodir_make.lo src/libs6/ftrigw_notify.lo src/libs6/ftrigw_notifyb.lo src/libs6/ftrigw_notifyb_nosig.lo src/libs6/s6_accessrules_backend_cdb.lo src/libs6/s6_accessrules_backend_fs.lo src/libs6/s6_accessrules_keycheck_ip4.lo src/libs6/s6_accessrules_keycheck_ip6.lo src/libs6/s6_accessrules_keycheck_reversedns.lo src/libs6/s6_accessrules_keycheck_uidgid.lo src/libs6/s6_accessrules_params_free.lo src/libs6/s6_accessrules_uidgid_cdb.lo src/libs6/s6_accessrules_uidgid_fs.lo src/libs6/s6_compat_el_semicolon.lo src/libs6/s6_dtally_pack.lo src/libs6/s6_dtally_unpack.lo src/libs6/s6_dtally_read.lo src/libs6/s6_dtally_write.lo src/libs6/s6_instance_chdirservice.lo src/libs6/s6_servicedir_file_list.lo src/libs6/s6_servicedir_instances_recreate_offline.lo src/libs6/s6_servicedir_instances_recreate_offline_tmp.lo src/libs6/s6_svc_ok.lo src/libs6/s6_svc_write.lo src/libs6/s6_svc_writectl.lo src/libs6/s6_svstatus_pack.lo src/libs6/s6_svstatus_read.lo src/libs6/s6_svstatus_unpack.lo src/libs6/s6_svstatus_write.lo src/libs6/s6_fdholder_delete.lo src/libs6/s6_fdholder_delete_async.lo src/libs6/s6_fdholder_end.lo src/libs6/s6_fdholder_getdump.lo src/libs6/s6_fdholder_list.lo src/libs6/s6_fdholder_list_async.lo src/libs6/s6_fdholder_list_cb.lo src/libs6/s6_fdholder_retrieve.lo src/libs6/s6_fdholder_retrieve_async.lo src/libs6/s6_fdholder_retrieve_cb.lo src/libs6/s6_fdholder_setdump.lo src/libs6/s6_fdholder_start.lo src/libs6/s6_fdholder_store.lo src/libs6/s6_fdholder_store_async.lo src/libs6/s6_supervise_link.lo src/libs6/s6_supervise_link_names.lo src/libs6/s6_supervise_unlink.lo src/libs6/s6_supervise_unlink_names.lo ifeq ($(strip $(STATIC_LIBS_ARE_PIC)),) libs6auto.a.xyzzy: src/libs6/s6_auto_write_logger.o src/libs6/s6_auto_write_logger_tmp.o src/libs6/s6_auto_write_logrun.o src/libs6/s6_auto_write_logrun_tmp.o src/libs6/s6_auto_write_service.o else diff --git a/src/include/s6/ftrigr.h b/src/include/s6/ftrigr.h index 30a7ca6..2e0f340 100644 --- a/src/include/s6/ftrigr.h +++ b/src/include/s6/ftrigr.h @@ -3,7 +3,6 @@ #ifndef S6_FTRIGR_H #define S6_FTRIGR_H -#include #include #include @@ -21,6 +20,13 @@ struct ftrigr_s } ; #define FTRIGR_ZERO { .client = SASSCLIENT_ZERO, .data = GENALLOC_ZERO } +typedef struct ftrigr_string_s ftrigr_string, *ftrigr_string_ref ; +struct ftrigr_string_s +{ + char *s ; + uint32_t len ; +} ; + extern int ftrigr_startf (ftrigr *, tain const *, tain *) ; #define ftrigr_startf_g(a, deadline) ftrigr_startf(a, (deadline), &STAMP) extern int ftrigr_start (ftrigr *, unsigned int) ; @@ -28,8 +34,7 @@ extern void ftrigr_end (ftrigr *) ; #define ftrigr_fd(a) sassclient_fd(&(a)->client) extern int ftrigr_update (ftrigr *) ; -extern int ftrigr_peek (ftrigr *, uint32_t, struct iovec *) ; -extern int ftrigr_peek1 (ftrigr *, uint32_t, char *) ; +extern int ftrigr_peek (ftrigr *, uint32_t, ftrigr_string *) ; extern int ftrigr_ack (ftrigr *, uint32_t) ; extern void ftrigr_release (ftrigr *, uint32_t) ; @@ -41,7 +46,7 @@ extern int ftrigr_unsubscribe (ftrigr *, uint32_t, tain const *, tain *) ; extern int ftrigr_wait_and (ftrigr *, uint32_t const *, unsigned int, tain const *, tain *) ; #define ftrigr_wait_and_g(a, list, len, deadline) ftrigr_wait_and(a, list, len, (deadline), &STAMP) -extern int ftrigr_wait_or (ftrigr *, uint32_t const *, unsigned int, struct iovec *, tain const *, tain *) ; +extern int ftrigr_wait_or (ftrigr *, uint32_t const *, unsigned int, ftrigr_string *, tain const *, tain *) ; #define ftrigr_wait_or_g(a, list, n, v, deadline) ftrigr_wait_or(a, list, n, v, (deadline), &STAMP) #endif diff --git a/src/libs6/deps-lib/s6 b/src/libs6/deps-lib/s6 index 74a30a7..6590d83 100644 --- a/src/libs6/deps-lib/s6 +++ b/src/libs6/deps-lib/s6 @@ -1,7 +1,6 @@ ftrigr_ack.o ftrigr_end.o ftrigr_peek.o -ftrigr_peek1.o ftrigr_release.o ftrigr_start.o ftrigr_startf.o diff --git a/src/libs6/ftrigr_peek.c b/src/libs6/ftrigr_peek.c index 155fce3..5107bae 100644 --- a/src/libs6/ftrigr_peek.c +++ b/src/libs6/ftrigr_peek.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include @@ -8,7 +7,7 @@ #include #include "ftrigr-internal.h" -int ftrigr_peek (ftrigr *a, uint32_t id, struct iovec *v) +int ftrigr_peek (ftrigr *a, uint32_t id, ftrigr_string *fs) { ftrigr_data *p = genalloc_s(ftrigr_data, &a->data) + id ; switch (p->status) @@ -16,8 +15,8 @@ int ftrigr_peek (ftrigr *a, uint32_t id, struct iovec *v) case EAGAIN : return 0 ; case 0 : { - v->iov_base = p->sa.s ; - v->iov_len = p->sa.len ; + fs->s = p->sa.s ; + fs->len = p->sa.len ; return 1 ; } default: break ; diff --git a/src/libs6/ftrigr_peek1.c b/src/libs6/ftrigr_peek1.c deleted file mode 100644 index 81059f7..0000000 --- a/src/libs6/ftrigr_peek1.c +++ /dev/null @@ -1,14 +0,0 @@ -/* ISC license. */ - -#include - -#include - -int ftrigr_peek1 (ftrigr *a, uint32_t id, char *c) -{ - struct iovec v ; - int r = ftrigr_peek(a, id, &v) ; - if (r <= 0) return r ; - *c = ((char *)v.iov_base)[v.iov_len - 1] ; - return 1 ; -} diff --git a/src/libs6/ftrigr_wait_and.c b/src/libs6/ftrigr_wait_and.c index 24e722f..0619b08 100644 --- a/src/libs6/ftrigr_wait_and.c +++ b/src/libs6/ftrigr_wait_and.c @@ -14,8 +14,8 @@ int ftrigr_wait_and (ftrigr *a, uint32_t const *list, unsigned int n, tain const { for (;;) { - struct iovec v ; - int r = ftrigr_peek(a, list[i], &v) ; + ftrigr_string fs ; + int r = ftrigr_peek(a, list[i], &fs) ; if (r == -1) return -1 ; if (r) break ; r = iopause_stamp(&x, 1, deadline, stamp) ; diff --git a/src/libs6/ftrigr_wait_or.c b/src/libs6/ftrigr_wait_or.c index 0ed41b7..799e2e0 100644 --- a/src/libs6/ftrigr_wait_or.c +++ b/src/libs6/ftrigr_wait_or.c @@ -1,13 +1,12 @@ /* ISC license. */ -#include #include #include #include -int ftrigr_wait_or (ftrigr *a, uint32_t const *list, unsigned int n, struct iovec *v, tain const *deadline, tain *stamp) +int ftrigr_wait_or (ftrigr *a, uint32_t const *list, unsigned int n, ftrigr_string *fs, tain const *deadline, tain *stamp) { iopause_fd x = { .fd = ftrigr_fd(a), .events = IOPAUSE_READ } ; for (;;) @@ -15,7 +14,7 @@ int ftrigr_wait_or (ftrigr *a, uint32_t const *list, unsigned int n, struct iove int r ; for (unsigned int i = 0 ; i < n ; i++) { - r = ftrigr_peek(a, list[i], v) ; + r = ftrigr_peek(a, list[i], fs) ; if (r == -1) return -1 ; if (r) return i ; } diff --git a/src/pipe-tools/s6-ftrig-listen.c b/src/pipe-tools/s6-ftrig-listen.c index 5fa3e33..48f5f6b 100644 --- a/src/pipe-tools/s6-ftrig-listen.c +++ b/src/pipe-tools/s6-ftrig-listen.c @@ -107,8 +107,8 @@ int main (int argc, char const **argv) unsigned int i = 0 ; while (i < n) { - struct iovec v ; - r = ftrigr_peek(&a, ids[i], &v) ; + ftrigr_string fs ; + r = ftrigr_peek(&a, ids[i], &fs) ; if (r == -1) strerr_diefu1sys(111, "ftrigr_check") ; else if (!r) i++ ; else if (wgolb & GOLB_OR) n = 0 ; diff --git a/src/pipe-tools/s6-ftrig-listen1.c b/src/pipe-tools/s6-ftrig-listen1.c index 1a08e6d..9ebd5ca 100644 --- a/src/pipe-tools/s6-ftrig-listen1.c +++ b/src/pipe-tools/s6-ftrig-listen1.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -51,7 +52,7 @@ int main (int argc, char const *const *argv) ftrigr a = FTRIGR_ZERO ; pid_t pid ; uint32_t id ; - struct iovec v[2] = { [1] = { .iov_base = "\n", .iov_len = 1 } } ; + ftrigr_string fs ; unsigned int golc ; PROG = "s6-ftrig-listen1" ; @@ -84,7 +85,7 @@ int main (int argc, char const *const *argv) for (;;) { - int r = ftrigr_peek(&a, id, &v[0]) ; + int r = ftrigr_peek(&a, id, &fs) ; if (r == -1) strerr_diefu1sys(111, "ftrigr_peek") ; if (r) break ; r = iopause_g(x, 2, &deadline) ; @@ -99,6 +100,7 @@ int main (int argc, char const *const *argv) if (ftrigr_update(&a) == -1) strerr_diefu1sys(111, "ftrigr_update") ; } + struct iovec v[2] = { { .iov_base = fs.s, .iov_len = fs.len }, { .iov_base = "\n", .iov_len = 1 } } ; if (allwritev(1, v, 2) < 2) strerr_diefu1sys(111, "write to stdout") ; _exit(0) ; } diff --git a/src/pipe-tools/s6-ftrig-wait.c b/src/pipe-tools/s6-ftrig-wait.c index 87b573d..e36fa2d 100644 --- a/src/pipe-tools/s6-ftrig-wait.c +++ b/src/pipe-tools/s6-ftrig-wait.c @@ -32,9 +32,9 @@ int main (int argc, char const *const *argv) tain deadline ; tain tto = TAIN_INFINITE_RELATIVE ; ftrigr a = FTRIGR_ZERO ; + ftrigr_string fs ; uint32_t id ; unsigned int golc ; - struct iovec v[2] = { [1] = { .iov_base = "\n", .iov_len = 1 } } ; PROG = "s6-ftrig-wait" ; golc = gol_main(argc, argv, 0, 0, rgola, GOLA_N, 0, wgola) ; @@ -54,8 +54,10 @@ int main (int argc, char const *const *argv) if (!ftrigr_startf_g(&a, &deadline)) strerr_diefu1sys(111, "ftrigr_startf") ; if (!ftrigr_subscribe_g(&a, &id, 0, 0, argv[0], argv[1], &deadline)) strerr_diefu4sys(111, "subscribe to ", argv[0], " with regexp ", argv[1]) ; - if (ftrigr_wait_or_g(&a, &id, 1, &v[0], &deadline) == -1) + if (ftrigr_wait_or_g(&a, &id, 1, &fs, &deadline) == -1) strerr_diefu2sys((errno == ETIMEDOUT) ? 99 : 111, "match regexp on ", argv[1]) ; + + struct iovec v[2] = { { .iov_base = fs.s, .iov_len = fs.len }, { .iov_base = "\n", .iov_len = 1 } } ; if (allwritev(1, v, 2) < siovec_len(v, 2)) strerr_diefu1sys(111, "write to stdout") ; _exit(0) ; } diff --git a/src/supervision/s6-notifyoncheck.c b/src/supervision/s6-notifyoncheck.c index f86b1e0..ba8e91d 100644 --- a/src/supervision/s6-notifyoncheck.c +++ b/src/supervision/s6-notifyoncheck.c @@ -85,13 +85,13 @@ static inline int handle_signals (pid_t pid, int *w) static int handle_event (ftrigr *a, uint32_t id, pid_t pid) { int r ; - struct iovec v ; + ftrigr_string fs ; if (ftrigr_update(a) == -1) strerr_diefu1sys(111, "ftrigr_update") ; - r = ftrigr_peek(a, id, &v) ; + r = ftrigr_peek(a, id, &fs) ; if (r == -1) strerr_diefu1sys(111, "ftrigr_check") ; if (r) { - if (memchr(v.iov_base, 'd', v.iov_len)) + if (memchr(fs.s, 'd', fs.len)) { if (pid) kill(pid, SIGTERM) ; ftrigr_ack(a, id) ; diff --git a/src/supervision/s6_svlisten_loop.c b/src/supervision/s6_svlisten_loop.c index 4a3e4cf..60e77ad 100644 --- a/src/supervision/s6_svlisten_loop.c +++ b/src/supervision/s6_svlisten_loop.c @@ -70,15 +70,14 @@ unsigned int s6_svlisten_loop (s6_svlisten_t *foo, int wantup, int wantready, in if (ftrigr_update(&foo->a) < 0) strerr_diefu1sys(111, "ftrigr_update") ; for (unsigned int i = 0 ; i < foo->n ; i++) { - struct iovec v ; - r = ftrigr_peek(&foo->a, foo->ids[i], &v) ; + ftrigr_string fs ; + r = ftrigr_peek(&foo->a, foo->ids[i], &fs) ; if (r == -1) strerr_diefu1sys(111, "ftrigr_check") ; else if (r) { - char const *s = v.iov_base ; - for (size_t j = 0 ; j < v.iov_len ; j++) + for (uint32_t j = 0 ; j < fs.len ; j++) { - if (s[j] == 'x') + if (fs.s[j] == 'x') { if (bitarray_peek(foo->upstate, i) != wantup || bitarray_peek(foo->readystate, i) != wantready) @@ -86,7 +85,7 @@ unsigned int s6_svlisten_loop (s6_svlisten_t *foo, int wantup, int wantready, in bitarray_poke(foo->upstate, i, wantup) ; bitarray_poke(foo->readystate, i, wantready) ; } - else if (s[j] == 'O') + else if (fs.s[j] == 'O') { if (wantup) { @@ -97,7 +96,7 @@ unsigned int s6_svlisten_loop (s6_svlisten_t *foo, int wantup, int wantready, in } else { - unsigned int d = byte_chr("dDuU", 4, s[j]) ; + unsigned int d = byte_chr("dDuU", 4, fs.s[j]) ; bitarray_poke(foo->upstate, i, d & 2) ; bitarray_poke(foo->readystate, i, d & 1) ; } -- cgit v1.3.1