summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2014-10-21 23:18:26 +0200
committerGuillem Jover <guillem@debian.org>2014-10-23 00:17:40 +0200
commitce27f5dc0c3dc6ed7656d09784ea461407765d7d (patch)
tree3672521d3ccf9752ed993f24b6aa98cda4eba375 /src
parent2867df049d99250b59c3449669541e370182af43 (diff)
downloaddpkg-ce27f5dc0c3dc6ed7656d09784ea461407765d7d.tar.gz
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.
Diffstat (limited to 'src')
-rw-r--r--src/filesdb.c1
-rw-r--r--src/main.h2
-rw-r--r--src/packages.c7
3 files changed, 10 insertions, 0 deletions
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) {