From 3304abe230be1639df327f6949e60261991b833d Mon Sep 17 00:00:00 2001 From: Jesse Smith Date: Fri, 16 Nov 2018 21:08:56 -0400 Subject: [PATCH] Applied patch from Francis Russell which should greatly speed up make-style dependency checking in startpar (Fracis's test suggest patch causes just 0.25% number of loop/dependency checks compared to original.) This should close Debian bugs which report startpar is bailing out when checking dependencies. Addresses Debian bugs #609959 and #696359. --- CHANGELOG | 9 ++++++++- makeboot.c | 24 ++++++++++++++++-------- makeboot.h | 1 + 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 63eba18..50e300e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,9 +1,16 @@ startpar 0.61 =============== -* Applied signal patch from Petter Heinholdtsen which shoudl avoid +* Applied signal patch from Petter Heinholdtsen which should avoid masking SIGINT to services. Addresses Debian bug #679630 +* Applied patch from Francis Russell which should greatly speed up + make-style dependency checking in startpar (Fracis's test + suggest patch causes just 0.25% number of loop/dependency checks + compared to original.) + This should close Debian bugs which report startpar is bailing + out when checking dependencies. + Addresses Debian bugs #609959 and #696359. startpar 0.60 diff --git a/makeboot.c b/makeboot.c index cb6fbdb..2b34408 100644 --- a/makeboot.c +++ b/makeboot.c @@ -47,6 +47,8 @@ static int o_flags = O_RDONLY; #endif #include "makeboot.h" +static int check_loop(struct makenode *dep, struct makenode *src); +static int check_loop_helper(struct makenode *dep, struct makenode *src); int tree_entries = 0; struct makenode *tree_list = NULL; @@ -85,6 +87,7 @@ static struct makenode *add_target(const char *name) } memset(node, 0, alignof(struct makenode)+strsize(name)); node->name = ((char*)node)+alignof(struct makenode); + node->cycle_check_value = -1; strcpy(node->name, name); /* append to the list in alphabetical order */ @@ -129,21 +132,27 @@ static struct makelist *new_list(struct makenode *node, struct makelist *next) /* * check whether the given target would create an infinte loop */ -static int loop; +static int cycle_check_value; static int check_loop(struct makenode *dep, struct makenode *src) { + ++cycle_check_value; + return check_loop_helper(dep, src); +} + +static int check_loop_helper(struct makenode *dep, struct makenode *src) +{ + if (dep->cycle_check_value == cycle_check_value) + return 0; + else + dep->cycle_check_value = cycle_check_value; + struct makelist *s; for (s = dep->depend; s; s = s->next) { if (s->node == src) { fprintf(stderr, "loop exists %s in %s!\n", dep->name, src->name); return 1; } - if (loop++ > 99999) { - fprintf(stderr, "too many loops! (loop=%d, dep->name=%s, src->name=%s)\n", - loop, dep->name, src->name); - return 1; - } - if (check_loop(s->node, src)) + if (check_loop_helper(s->node, src)) return 1; } return 0; @@ -157,7 +166,6 @@ static void add_depend(struct makenode *node, const char *dst) struct makenode *dep; dep = add_target(dst); - loop = 0; if (check_loop(dep, node)) return; dep->select = new_list(node, dep->select); diff --git a/makeboot.h b/makeboot.h index 79e5233..c6cf355 100644 --- a/makeboot.h +++ b/makeboot.h @@ -35,6 +35,7 @@ struct makenode { struct makenode *next; int interactive; int importance; + int cycle_check_value; int filter_prefix; };