summaryrefslogtreecommitdiff
path: root/src/libs6
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2015-07-20 20:20:54 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2015-07-20 20:20:54 +0000
commita3cdeecf0033919e3b5a79c17c19b5ac98719256 (patch)
tree92a930930f18a4f8ae897b1a69c39358137ce1e2 /src/libs6
parentbd34de9054cec794d96b0fde1eee9100e1d34215 (diff)
downloads6-a3cdeecf0033919e3b5a79c17c19b5ac98719256.tar.xz
- 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
Diffstat (limited to 'src/libs6')
-rw-r--r--src/libs6/deps-lib/s61
-rw-r--r--src/libs6/s6_svc_writectl.c16
-rw-r--r--src/libs6/s6_svstatus_pack.c15
-rw-r--r--src/libs6/s6_svstatus_unpack.c37
4 files changed, 41 insertions, 28 deletions
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 <skalibs/bytestr.h>
+#include <s6/s6-supervise.h>
+
+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 <skalibs/uint32.h>
+#include <skalibs/uint16.h>
#include <skalibs/uint64.h>
#include <skalibs/tai.h>
#include <s6/s6-supervise.h>
@@ -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 <skalibs/uint32.h>
+#include <sys/types.h>
+#include <skalibs/uint16.h>
#include <skalibs/uint64.h>
#include <skalibs/tai.h>
#include <s6/s6-supervise.h>
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) ;
}