diff options
author | Guillem Jover <guillem@debian.org> | 2012-04-01 07:55:36 +0200 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2013-04-14 05:50:17 +0200 |
commit | 08d1abf93b29b9edbedf7353b2c67761b04b3a2b (patch) | |
tree | 7ed87cf87d9bf9ef89517d721f24f02a260a7691 /src/trigproc.c | |
parent | dabcb9560063a134a01c4223b1d6fa3624175daa (diff) | |
download | dpkg-08d1abf93b29b9edbedf7353b2c67761b04b3a2b.tar.gz |
dpkg: Refactor tortoise_not_in_hare() out from check_trigger_cycle()
Diffstat (limited to 'src/trigproc.c')
-rw-r--r-- | src/trigproc.c | 79 |
1 files changed, 44 insertions, 35 deletions
diff --git a/src/trigproc.c b/src/trigproc.c index 98c7fcf97..59129adda 100644 --- a/src/trigproc.c +++ b/src/trigproc.c @@ -168,6 +168,48 @@ trigproc_reset_cycle(void) tortoise = hare = NULL; } +static bool +tortoise_not_in_hare(struct pkginfo *processing_now, + struct trigcycleperpkg *tortoise_pkg) +{ + const char *processing_now_name, *tortoise_name; + struct trigpend *hare_trig, *tortoise_trig; + + processing_now_name = pkg_name(processing_now, pnaw_nonambig); + tortoise_name = pkg_name(tortoise_pkg->pkg, pnaw_nonambig); + + debug(dbg_triggersdetail, "%s pnow=%s tortoise=%s", __func__, + processing_now_name, tortoise_name); + for (tortoise_trig = tortoise_pkg->then_trigs; + tortoise_trig; + tortoise_trig = tortoise_trig->next) { + debug(dbg_triggersdetail, + "%s pnow=%s tortoise=%s tortoisetrig=%s", __func__, + processing_now_name, tortoise_name, tortoise_trig->name); + + /* hare is now so we can just look up in the actual data. */ + for (hare_trig = tortoise_pkg->pkg->trigpend_head; + hare_trig; + hare_trig = hare_trig->next) { + debug(dbg_triggersstupid, "%s pnow=%s tortoise=%s" + " tortoisetrig=%s haretrig=%s", __func__, + processing_now_name, tortoise_name, + tortoise_trig->name, hare_trig->name); + if (strcmp(hare_trig->name, tortoise_trig->name) == 0) + break; + } + + if (hare_trig == NULL) { + /* Not found in hare, yay! */ + debug(dbg_triggersdetail, "%s pnow=%s tortoise=%s OK", + __func__, processing_now_name, tortoise_name); + return true; + } + } + + return false; +} + /* * Returns package we're to give up on. */ @@ -176,7 +218,7 @@ check_trigger_cycle(struct pkginfo *processing_now) { struct trigcyclenode *tcn; struct trigcycleperpkg *tcpp, *tortoise_pkg; - struct trigpend *hare_trig, *tortoise_trig; + struct trigpend *tortoise_trig; struct pkgiterator *it; struct pkginfo *pkg, *giveup; const char *sep; @@ -221,41 +263,8 @@ check_trigger_cycle(struct pkginfo *processing_now) for (tortoise_pkg = tortoise->pkgs; tortoise_pkg; tortoise_pkg = tortoise_pkg->next) { - const char *processing_now_name, *tortoise_name; - - processing_now_name = pkg_name(processing_now, pnaw_nonambig); - tortoise_name = pkg_name(tortoise_pkg->pkg, pnaw_nonambig); - - debug(dbg_triggersdetail, "check_triggers_cycle pnow=%s tortoise=%s", - processing_now_name, tortoise_name); - for (tortoise_trig = tortoise_pkg->then_trigs; - tortoise_trig; - tortoise_trig = tortoise_trig->next) { - debug(dbg_triggersdetail, - "check_triggers_cycle pnow=%s tortoise=%s" - " tortoisetrig=%s", - processing_now_name, tortoise_name, - tortoise_trig->name); - /* hare is now so we can just look up in the actual - * data. */ - for (hare_trig = tortoise_pkg->pkg->trigpend_head; - hare_trig; - hare_trig = hare_trig->next) { - debug(dbg_triggersstupid, - "check_triggers_cycle pnow=%s tortoise=%s" - " tortoisetrig=%s haretrig=%s", - processing_now_name, tortoise_name, - tortoise_trig->name, hare_trig->name); - if (strcmp(hare_trig->name, tortoise_trig->name) == 0) - goto found_in_hare; - } - /* Not found in hare, yay! */ - debug(dbg_triggersdetail, - "check_triggers_cycle pnow=%s tortoise=%s OK", - processing_now_name, tortoise_name); + if (tortoise_not_in_hare(processing_now, tortoise_pkg)) return NULL; - found_in_hare:; - } } /* Oh dear. hare is a superset of tortoise. We are making no * progress. */ |