summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2021-06-27 14:51:37 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2021-06-27 14:51:37 +0000
commitc26824e1f078b8de0d38cb87d3f291235ab5cf76 (patch)
treefc52ce6341ddec8928a358d67d6764f979e8c3e2
parentb692b00052383b6be4c1f7a72505a59103253db5 (diff)
downloads6-rc-c26824e1f078b8de0d38cb87d3f291235ab5cf76.tar.xz
Some brainstorming on dependencies, transitions, service types
-rw-r--r--src/include/s6-rc/event.h25
-rw-r--r--src/server/service.c18
-rw-r--r--src/server/service.h108
-rw-r--r--src/server/transition.h4
4 files changed, 135 insertions, 20 deletions
diff --git a/src/include/s6-rc/event.h b/src/include/s6-rc/event.h
index 8a08dcb..f99b571 100644
--- a/src/include/s6-rc/event.h
+++ b/src/include/s6-rc/event.h
@@ -5,28 +5,15 @@
#include <stdint.h>
-
-typedef enum s6rc_eventtype_e s6rc_eventtype_t, *s6rc_eventtype_t_ref ;
-enum s6rc_eventtype_e
-{
- S6RC_EVENTTYPE_WANTED_STATE_DOWN,
- S6RC_EVENTTYPE_WANTED_STATE_UP,
- S6RC_EVENTTYPE_CURRENT_STATE_DOWN,
- S6RC_EVENTTYPE_CURRENT_STATE_UP,
- S6RC_EVENTTYPE_TRANSITION_STOP,
- S6RC_EVENTTYPE_TRANSITION_START,
- S6RC_EVENTTYPE_CUSTOM, /* for misc events from other processes */
- S6RC_EVENTTYPE_PHAIL
-} ;
-
typedef struct s6rc_event_s s6rc_event_t, *s6rc_event_t_ref ;
struct s6rc_event_s
{
- char const *name ;
- uint32_t value ;
- uint8_t type : 3 ;
- uint8_t extra : 5 ;
+ uint32_t name ;
+ uint32_t instance ;
+ uint8_t wanted : 1 ;
+ uint8_t up : 1 ;
+ uint8_t extra : 6 ;
} ;
-#define S6RC_EVENT_ZERO { .name = 0, .value = 0, .type = S6RC_EVENTTYPE_PHAIL, .extra = 0 }
+#define S6RC_EVENT_ZERO { .name = 0, .instance = 0, .wanted = 0, .updown = 0, .extra = 0 }
#endif
diff --git a/src/server/service.c b/src/server/service.c
new file mode 100644
index 0000000..b5d06f4
--- /dev/null
+++ b/src/server/service.c
@@ -0,0 +1,18 @@
+/* ISC license. */
+
+#include "service.h"
+
+common_t const *service_common (db_t const *db, stype_t stype, uint32_t i)
+{
+ if (stype >= STYPE_PHAIL) return 0 ;
+ if (i >= db->n[stype]) return 0 ;
+ switch (stype)
+ {
+ case STYPE_LONGRUN : return &db->longruns[i].common ;
+ case STYPE_ONESHOT : return &db->oneshots[i].common ;
+ case STYPE_EXTERNAL : return &db->externals[i].common ;
+ case STYPE_BUNDLE : return &db->bundles[i].common ;
+ case STYPE_VIRTUAL : return &db->virtuals[i].common ;
+ default : return 0 ;
+ }
+}
diff --git a/src/server/service.h b/src/server/service.h
new file mode 100644
index 0000000..86ee341
--- /dev/null
+++ b/src/server/service.h
@@ -0,0 +1,108 @@
+/* ISC license. */
+
+#ifndef S6RCD_SERVICE_H
+#define S6RCD_SERVICE_H
+
+#include <stdint.h>
+
+#include <skalibs/stralloc.h>
+
+
+ /* Service types and db representation in memory */
+
+typedef enum stype_e stype_t, *stype_t_ref ;
+enum stype_e
+{
+ STYPE_LONGRUN,
+ STYPE_ONESHOT,
+ STYPE_EXTERNAL,
+ STYPE_BUNDLE,
+ STYPE_VIRTUAL,
+ STYPE_PHAIL
+} ;
+
+typedef struct common_s common_t, *common_t_ref ;
+struct common_s
+{
+ uint32_t name ;
+ uint32_t deps[2] ;
+ uint32_t ndeps[2] ;
+ uint32_t flag_dynamic : 1 ;
+ uint32_t flag_essential : 1 ;
+ uint32_t flags : 30 ;
+} ;
+
+typedef struct satomic_s satomic_t, *satomic_t_ref ;
+struct satomic_s
+{
+ common_t common ;
+ uint32_t timeout[2] ;
+} ;
+
+typedef struct oneshot_s oneshot_t, *oneshot_t_ref ;
+struct oneshot_s
+{
+ satomic_t satomic ;
+ uint32_t argc[2] ;
+ uint32_t argv[2] ;
+} ;
+
+typedef struct longrun_s longrun_t, *longrun_t_ref ;
+struct longrun_s
+{
+ satomic_t satomic ;
+ uint32_t consumer ;
+ uint32_t nproducers ;
+ uint32_t producers ;
+} ;
+
+typedef struct external_s external_t, *external_t_ref ;
+struct external_s
+{
+ common_t common ;
+} ;
+
+typedef struct bundle_s bundle_t, *bundle_t_ref ;
+struct bundle_s
+{
+ common_t common ;
+ uint32_t ncontents ;
+ uint32_t contents ;
+} ;
+
+typedef struct virtual_s virtual_t, *virtual_t_ref ;
+struct virtual_s
+{
+ common_t common ;
+ uint32_t ncontents ;
+ uint32_t contents ;
+} ;
+
+typedef struct deptype_s deptype_t, *deptype_t_ref ;
+struct deptype_s
+{
+ uint8_t passive : 1 ;
+ uint8_t soft : 1 ;
+ uint8_t loose : 1 ;
+} ;
+
+typedef struct db_s db_t, *db_t_ref ;
+struct db_s
+{
+ uint32_t n[STYPE_PHAIL] ;
+ longrun_t *longruns ;
+ oneshot_t *oneshots ;
+ external_t *externals ;
+ bundle_t *bundles ;
+ virtual_t *virtuals ;
+ char const **argvs ;
+ uint32_t *deps[2] ;
+ deptype_t *deptypes[2] ;
+ uint32_t *producers ;
+ char *storage ;
+ uint32_t storagelen ;
+} ;
+
+extern common_t const *service_common (db_t const *, stype_t, uint32_t) ;
+
+#endif
diff --git a/src/server/transition.h b/src/server/transition.h
index fcddfa6..3ade951 100644
--- a/src/server/transition.h
+++ b/src/server/transition.h
@@ -13,8 +13,10 @@ typedef struct transition_s transition_t, *transition_t_ref ;
struct transition_s
{
pid_t pid ;
+ uint32_t service ;
+ uint8_t updown : 1 ;
} ;
-#define TRANSITION_ZERO { .pid = 0 }
+#define TRANSITION_ZERO { .pid = 0, .service = 0, }
extern uint32_t ntransitions ;
transitions_t *transitions ;