From a3cdeecf0033919e3b5a79c17c19b5ac98719256 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Mon, 20 Jul 2015 20:20:54 +0000 Subject: - Add timeout-finish support and "down-readiness" - LOTS of refactoring to make this work - Remove s6-notifywhenup - s6-supervise now rocks the casbah - rc for 2.2.0.0 --- src/libs6/deps-lib/s6 | 1 + src/libs6/s6_svc_writectl.c | 16 ++++++++++++++++ src/libs6/s6_svstatus_pack.c | 15 ++++++++++----- src/libs6/s6_svstatus_unpack.c | 37 ++++++++++++++----------------------- 4 files changed, 41 insertions(+), 28 deletions(-) create mode 100644 src/libs6/s6_svc_writectl.c (limited to 'src/libs6') diff --git a/src/libs6/deps-lib/s6 b/src/libs6/deps-lib/s6 index 01b67c3..093db6a 100644 --- a/src/libs6/deps-lib/s6 +++ b/src/libs6/deps-lib/s6 @@ -26,6 +26,7 @@ s6_accessrules_uidgid_fs.o s6_supervise_lock.o s6_supervise_lock_mode.o s6_svc_write.o +s6_svc_writectl.o s6_svstatus_pack.o s6_svstatus_read.o s6_svstatus_unpack.o diff --git a/src/libs6/s6_svc_writectl.c b/src/libs6/s6_svc_writectl.c new file mode 100644 index 0000000..2e308b9 --- /dev/null +++ b/src/libs6/s6_svc_writectl.c @@ -0,0 +1,16 @@ +/* ISC license. */ + +#include +#include + +int s6_svc_writectl (char const *service, char const *subdir, char const *s, unsigned int len) +{ + unsigned int svlen = str_len(service) ; + unsigned int sublen = str_len(subdir) ; + char fn[svlen + sublen + 10] ; + byte_copy(fn, svlen, service) ; + fn[svlen] = '/' ; + byte_copy(fn + svlen + 1, sublen, subdir) ; + byte_copy(fn + svlen + 1 + sublen, 9, "/control") ; + return s6_svc_write(fn, s, len) ; +} diff --git a/src/libs6/s6_svstatus_pack.c b/src/libs6/s6_svstatus_pack.c index 2b1f102..cc92621 100644 --- a/src/libs6/s6_svstatus_pack.c +++ b/src/libs6/s6_svstatus_pack.c @@ -1,6 +1,6 @@ /* ISC license. */ -#include +#include #include #include #include @@ -8,8 +8,13 @@ void s6_svstatus_pack (char *pack, s6_svstatus_t const *sv) { tain_pack(pack, &sv->stamp) ; - uint32_pack(pack + 12, (uint32)sv->pid) ; - pack[16] = sv->flagpaused | (sv->flagfinishing << 1) ; - pack[17] = sv->flagwant ? sv->flagwantup ? 'u' : 'd' : 0 ; - uint64_pack(pack + 18, (uint64)sv->wstat) ; + tain_pack(pack + 12, &sv->readystamp) ; + uint64_pack_big(pack + 24, (uint64)sv->pid) ; + uint16_pack_big(pack + 32, (uint16)sv->wstat) ; + pack[34] = + sv->flagpaused | + (sv->flagfinishing << 1) | + (sv->flagwant << 2) | + (sv->flagwantup << 3) | + (sv->flagready << 4) ; } diff --git a/src/libs6/s6_svstatus_unpack.c b/src/libs6/s6_svstatus_unpack.c index 3fbc205..2e78dcb 100644 --- a/src/libs6/s6_svstatus_unpack.c +++ b/src/libs6/s6_svstatus_unpack.c @@ -1,33 +1,24 @@ /* ISC license. */ -#include +#include +#include #include #include #include void s6_svstatus_unpack (char const *pack, s6_svstatus_t *sv) { - uint32 pid ; - uint64 wstat ; + uint64 pid ; + uint16 wstat ; tain_unpack(pack, &sv->stamp) ; - uint32_unpack(pack + 12, &pid) ; - sv->pid = (unsigned int)pid ; - uint64_unpack(pack + 18, &wstat) ; - sv->wstat = (unsigned int)wstat ; - sv->flagpaused = pack[16] & 1 ; - sv->flagfinishing = (pack[16] >> 1) & 1 ; - switch (pack[17]) - { - case 'u' : - sv->flagwant = 1 ; - sv->flagwantup = 1 ; - break ; - case 'd' : - sv->flagwant = 1 ; - sv->flagwantup = 0 ; - break ; - default : - sv->flagwant = 0 ; - sv->flagwantup = 0 ; - } + tain_unpack(pack + 12, &sv->readystamp) ; + uint64_unpack_big(pack + 24, &pid) ; + sv->pid = (pid_t)pid ; + uint16_unpack_big(pack + 32, &wstat) ; + sv->wstat = (int)wstat ; + sv->flagpaused = pack[34] & 1 ; + sv->flagfinishing = !!(pack[34] & 2) ; + sv->flagwant = !!(pack[34] & 4) ; + sv->flagwantup = !!(pack[34] & 8) ; + sv->flagready = !!(pack[34] & 16) ; } -- cgit v1.2.3