diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2017-11-04 13:19:12 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2017-11-04 13:19:12 +0000 |
commit | c681d62a23a8b4ca2ecf0d6291a208ca323f0171 (patch) | |
tree | d69aed5c6dbab88ca8f781d6a345f0725a1d695e /src/libs6rc/s6rc_db_read.c | |
parent | bc64800b5399e3dabaf1e7d7bc13b14a2dc4bf42 (diff) | |
download | s6-rc-c681d62a23a8b4ca2ecf0d6291a208ca323f0171.tar.xz |
Implement funnels. Needs testing.
Diffstat (limited to 'src/libs6rc/s6rc_db_read.c')
-rw-r--r-- | src/libs6rc/s6rc_db_read.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/libs6rc/s6rc_db_read.c b/src/libs6rc/s6rc_db_read.c index b3f9aed..717382f 100644 --- a/src/libs6rc/s6rc_db_read.c +++ b/src/libs6rc/s6rc_db_read.c @@ -11,7 +11,7 @@ #ifdef DEBUG #include <skalibs/lolstdio.h> -#define DBG(...) do { bprintf(buffer_2, "debug: ") ; bprintf(buffer_2, __VA_ARGS__) ; bprintf(buffer_2, "\n") ; buffer_flush(buffer_2) ; } while(0) +#define DBG(...) LOLDEBUG(__VA_ARGS__) #else #define DBG(...) #endif @@ -33,19 +33,19 @@ static inline int s6rc_db_check_valid_strings (char const *string, size_t string return 1 ; } -static inline int s6rc_db_read_deps (buffer *b, unsigned int max, uint32_t *deps, unsigned int ndeps) +static inline int s6rc_db_read_uints (buffer *b, unsigned int max, uint32_t *p, unsigned int n) { uint32_t x ; - ndeps <<= 1 ; - while (ndeps--) + while (n--) { if (!s6rc_db_read_uint32(b, &x)) return -1 ; if (x >= max) return 0 ; - *deps++ = x ; + *p++ = x ; } return 1 ; } + static inline int s6rc_db_read_services (buffer *b, s6rc_db_t *db) { unsigned int n = db->nshort + db->nlong ; @@ -89,8 +89,9 @@ static inline int s6rc_db_read_services (buffer *b, s6rc_db_t *db) #endif if (i < db->nlong) { - if (!s6rc_db_read_uint32(b, &sv->x.longrun.pipeline[0])) return -1 ; - if (!s6rc_db_read_uint32(b, &sv->x.longrun.pipeline[1])) return -1 ; + if (!s6rc_db_read_uint32(b, &sv->x.longrun.consumer)) return -1 ; + if (!s6rc_db_read_uint32(b, &sv->x.longrun.nproducers)) return -1 ; + if (!s6rc_db_read_uint32(b, &sv->x.longrun.producers)) return -1 ; } else { @@ -141,7 +142,9 @@ static inline int s6rc_db_read_buffer (buffer *b, s6rc_db_t *db) { int r = s6rc_db_read_string(b, db->string, db->stringlen) ; if (r < 1) return r ; - r = s6rc_db_read_deps(b, db->nshort + db->nlong, db->deps, db->ndeps) ; + r = s6rc_db_read_uints(b, db->nshort + db->nlong, db->deps, db->ndeps << 1) ; + if (r < 1) return r ; + r = s6rc_db_read_uints(b, db->nlong, db->producers, db->nproducers) ; if (r < 1) return r ; r = s6rc_db_read_services(b, db) ; if (r < 1) return r ; |