From 7ad2e38bf5c0d417288d458b1fbcd69dab5c4a07 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Wed, 12 Aug 2015 20:02:32 +0000 Subject: Would be better if git commit -a actually picked up the new files... --- src/libs6rc/s6rc_db_check_pipelines.c | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/libs6rc/s6rc_db_check_pipelines.c (limited to 'src') diff --git a/src/libs6rc/s6rc_db_check_pipelines.c b/src/libs6rc/s6rc_db_check_pipelines.c new file mode 100644 index 0000000..19dc141 --- /dev/null +++ b/src/libs6rc/s6rc_db_check_pipelines.c @@ -0,0 +1,48 @@ +/* ISC license. */ + +#include +#include +#include +#include +#include + +int s6rc_db_check_pipelines (s6rc_db_t const *db, diuint32 *problem) +{ + uint32 i = db->nlong ; + unsigned char black[bitarray_div8(db->nlong)] ; + byte_zero(black, bitarray_div8(db->nlong)) ; + while (i--) if (!bitarray_peek(black, i)) + { + uint32 j = i ; + uint32 start ; + for (;;) + { + register uint32 k = db->services[j].x.longrun.pipeline[0] ; + if (k >= db->nlong) break ; + if (k == i || bitarray_peek(black, k)) + { + problem->left = i ; + problem->right = k ; + return 1 + (k == i) ; + } + j = k ; + } + start = j ; + j = i ; + for (;;) + { + register unsigned int k = db->services[j].x.longrun.pipeline[1] ; + if (k >= db->nlong) break ; + if (k == i || bitarray_peek(black, k)) + { + problem->left = i ; + problem->right = k ; + return 1 + (k == i) ; + } + j = k ; + } + for (j = start ; j > db->nlong ; j = db->services[j].x.longrun.pipeline[1]) + bitarray_set(black, j) ; + } + return 0 ; +} -- cgit v1.2.3