summaryrefslogtreecommitdiff
path: root/src/server/state.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/state.h')
-rw-r--r--src/server/state.h48
1 files changed, 30 insertions, 18 deletions
diff --git a/src/server/state.h b/src/server/state.h
index 2690f45..2084437 100644
--- a/src/server/state.h
+++ b/src/server/state.h
@@ -3,44 +3,56 @@
#ifndef S6RCD_STATE_H
#define S6RCD_STATE_H
+#include <stdint.h>
+
#include <skalibs/genalloc.h>
#include "db.h"
/* Service states, instances, machine state */
-typedef struct stateatom_s stateatom_t, *stateatom_t_ref ;
-struct stateatom_s
+#define SSTATE_STABLE 0x00u
+#define SSTATE_WAITING 0x01u
+#define SSTATE_TRANSITIONING 0x02u
+#define SSTATE_FAILED 0x03u
+
+#define SSTATE_CURRENT 0x04u
+#define SSTATE_WANTED 0x08u
+#define SSTATE_EXPLICIT 0x10u
+#define SSTATE_GRAY 0x20u
+#define SSTATE_BLACK 0x40u
+#define SSTATE_INVALID 0x80u
+
+typedef struct sstate_s sstate_t, *sstate_t_ref ;
+struct sstate_s
{
- uint8_t wanted : 1 ;
- uint8_t current : 1 ;
- uint8_t transitioning : 1 ;
-} ;
-#define STATEATOM_ZERO { .wanted = 0, .current = 0, .transitioning = 0 }
+ uint8_t bits ;
+}
typedef struct instance_s instance_t, *instance_t_ref ;
struct instance_s
{
char const *param ; /* refcounted pointer to dynstorage */
- stateatom_t state ;
+ sstate_t sstate ;
} ;
-typedef struct state_s state_t, *state_t_ref ;
-struct state_s
+typedef struct mstate_s mstate_t, *mstate_t_ref ;
+struct mstate_s
{
- stateatom_t *sta[S6RC_STYPE_PHAIL] ;
- genalloc *dyn[S6RC_STYPE_PHAIL] ; /* every genalloc is a list of instance_t */
+ sstate_t *sta[S6RC_STYPE_N] ;
+ genalloc *dyn[S6RC_STYPE_N] ; /* every genalloc is a list of instance_t */
} ;
extern void instance_free (instance_t *) ;
-extern int instance_new (instance_t *, stateatom_t const *, char const *) ;
+extern int instance_new (instance_t *, uint8_t *, char const *) ;
-extern void state_free (state_t *, uint32_t const *) ;
-extern int state_init (state_t *, uint32_t const *) ;
+extern void mstate_free (mstate_t *, uint32_t const *) ;
+extern int mstate_init (mstate_t *, uint32_t const *) ;
-extern int state_write (char const *, state_t const *, uint32_t const *) ;
-extern int state_read (char const *, state_t *, uint32_t const *) ; /* also inits */
+extern int mstate_write (char const *, mstate_t const *, uint32_t const *) ;
+extern int mstate_read (char const *, mstate_t *, uint32_t const *) ; /* also inits */
-extern stateatom_t *state_atom (s6rc_db_t const *, state_t const *, s6rc_sid_t const *) ;
+extern sstate_t *sstate_get (s6rc_db_t const *, mstate_t const *, s6rc_id_t, char const *) ;
+extern int sstate_deps_fulfilled (s6rc_db_t const *, mstate_t const *, s6rc_id_t, char const *, int) ;
#endif