diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2017-12-22 17:37:09 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2017-12-22 17:37:09 +0000 |
commit | d7242bda59ec2ec056508b39cb532b5e7318dd13 (patch) | |
tree | ffb04351e694d0f7935062127daf0d1b47ebf3d2 /src/libs6/s6lock_update.c | |
parent | da7304bbbfb90ced7a00acf5dbca0319d89fcc3a (diff) | |
download | s6-d7242bda59ec2ec056508b39cb532b5e7318dd13.tar.xz |
Port ftrigr and s6lock to textclient
Diffstat (limited to 'src/libs6/s6lock_update.c')
-rw-r--r-- | src/libs6/s6lock_update.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/libs6/s6lock_update.c b/src/libs6/s6lock_update.c index a56c276..9795d9d 100644 --- a/src/libs6/s6lock_update.c +++ b/src/libs6/s6lock_update.c @@ -1,25 +1,26 @@ /* ISC license. */ +#include <sys/uio.h> #include <stdint.h> #include <errno.h> #include <skalibs/error.h> #include <skalibs/uint16.h> #include <skalibs/genalloc.h> #include <skalibs/gensetdyn.h> -#include <skalibs/unixmessage.h> -#include <skalibs/skaclient.h> +#include <skalibs/textclient.h> #include <s6/s6lock.h> -static int msghandler (unixmessage_t const *m, void *context) +static int msghandler (struct iovec const *v, void *context) { s6lock_t *a = (s6lock_t *)context ; + char const *s = v->iov_base ; char *p ; uint16_t id ; - if (m->len != 3 || m->nfds) return (errno = EPROTO, 0) ; - uint16_unpack_big(m->s, &id) ; + if (v->iov_len != 3) return (errno = EPROTO, 0) ; + uint16_unpack_big(s, &id) ; p = GENSETDYN_P(char, &a->data, id) ; - if (*p == EBUSY) *p = m->s[2] ; - else if (error_isagain(*p)) *p = m->s[2] ? m->s[2] : EBUSY ; + if (*p == EBUSY) *p = s[2] ; + else if (error_isagain(*p)) *p = s[2] ? s[2] : EBUSY ; else return (errno = EPROTO, 0) ; if (!genalloc_append(uint16_t, &a->list, &id)) return 0 ; return 1 ; @@ -28,5 +29,5 @@ static int msghandler (unixmessage_t const *m, void *context) int s6lock_update (s6lock_t *a) { genalloc_setlen(uint16_t, &a->list, 0) ; - return skaclient_update(&a->connection, &msghandler, a) ; + return textclient_update(&a->connection, &msghandler, a) ; } |