]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/transaction: use hashmap_remove_value() to make not remove job with same ID
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 26 Apr 2023 04:59:34 +0000 (13:59 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 26 Apr 2023 15:35:54 +0000 (00:35 +0900)
When we fail to deserialize job ID, or the current_job_id is overflowed,
we may have jobs with the same ID.
This is paranoia, and just for safety.
Note, we already use hashmap_remove_value() in job_uninstall().

src/core/transaction.c

index 059558ebc0a8b18a6e83b4685f3863f7529a2f9d..cd0c28123f27db22a12c93938fb2a19d0b4eaf23 100644 (file)
@@ -662,7 +662,7 @@ static int transaction_apply(
                         /* j has been merged into a previously installed job */
                         if (tr->anchor_job == j)
                                 tr->anchor_job = installed_job;
-                        hashmap_remove(m->jobs, UINT32_TO_PTR(j->id));
+                        hashmap_remove_value(m->jobs, UINT32_TO_PTR(j->id), j);
                         job_free(j);
                         j = installed_job;
                 }
@@ -683,7 +683,7 @@ static int transaction_apply(
 rollback:
 
         HASHMAP_FOREACH(j, tr->jobs)
-                hashmap_remove(m->jobs, UINT32_TO_PTR(j->id));
+                hashmap_remove_value(m->jobs, UINT32_TO_PTR(j->id), j);
 
         return r;
 }