From ce27f5dc0c3dc6ed7656d09784ea461407765d7d Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Tue, 21 Oct 2014 23:18:26 +0200 Subject: dpkg: Add a requeueing insertion protection for process_queue() We should not requeue packages already in the queue. Just protect it in a similar way in how the deferred triggers queue is protected. In the future these can be unified. --- src/filesdb.c | 1 + src/main.h | 2 ++ src/packages.c | 7 +++++++ 3 files changed, 10 insertions(+) (limited to 'src') diff --git a/src/filesdb.c b/src/filesdb.c index fc8dd55fc..59d93e14c 100644 --- a/src/filesdb.c +++ b/src/filesdb.c @@ -105,6 +105,7 @@ ensure_package_clientdata(struct pkginfo *pkg) pkg->clientdata = nfmalloc(sizeof(struct perpackagestate)); pkg->clientdata->istobe = PKG_ISTOBE_NORMAL; pkg->clientdata->color = PKG_CYCLE_WHITE; + pkg->clientdata->enqueued = false; pkg->clientdata->fileslistvalid = false; pkg->clientdata->files = NULL; pkg->clientdata->replacingfilesandsaid = 0; diff --git a/src/main.h b/src/main.h index 57854277f..eafea872f 100644 --- a/src/main.h +++ b/src/main.h @@ -50,6 +50,8 @@ struct perpackagestate { /** Used during cycle detection. */ enum pkg_cycle_color color; + bool enqueued; + /** * filelistvalid files Meaning * ------------- ----- ------- diff --git a/src/packages.c b/src/packages.c index 5a14599ef..29517c7ed 100644 --- a/src/packages.c +++ b/src/packages.c @@ -56,6 +56,10 @@ int sincenothing = 0, dependtry = 0; void enqueue_package(struct pkginfo *pkg) { + ensure_package_clientdata(pkg); + if (pkg->clientdata->enqueued) + return; + pkg->clientdata->enqueued = true; pkg_queue_push(&queue, pkg); } @@ -208,6 +212,9 @@ void process_queue(void) { if (!pkg) continue; /* Duplicate, which we removed earlier. */ + ensure_package_clientdata(pkg); + pkg->clientdata->enqueued = false; + action_todo = cipaction->arg_int; if (sincenothing++ > queue.length * 2 + 2) { -- cgit v1.2.3