Просмотр исходного кода

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.
Guillem Jover лет назад: 11
Родитель
Сommit
ce27f5dc0c
4 измененных файлов с 13 добавлено и 0 удалено
  1. 3 0
      debian/changelog
  2. 1 0
      src/filesdb.c
  3. 2 0
      src/main.h
  4. 7 0
      src/packages.c

+ 3 - 0
debian/changelog

@@ -1,5 +1,8 @@
 dpkg (1.17.20) UNRELEASED; urgency=low
 
+  [ Guillem Jover ]
+  * Add a requeueing insertion protection for process_queue().
+
   [ Updated programs translations ]
   * German (Sven Joachim).
   * Simplified Chinese (Zhou Mo).

+ 1 - 0
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;

+ 2 - 0
src/main.h

@@ -50,6 +50,8 @@ struct perpackagestate {
   /** Used during cycle detection. */
   enum pkg_cycle_color color;
 
+  bool enqueued;
+
   /**
    * filelistvalid  files  Meaning
    * -------------  -----  -------

+ 7 - 0
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) {