Skip to content

Commit 13bc313

Browse files
yuwatabluca
authored andcommitted
core/transaction: use hashmap_remove_value() to make not remove job with same ID
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(). (cherry picked from commit c49dfd8) (cherry picked from commit 53ac14a)
1 parent 29fb56c commit 13bc313

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/core/transaction.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ static int transaction_apply(
662662
/* j has been merged into a previously installed job */
663663
if (tr->anchor_job == j)
664664
tr->anchor_job = installed_job;
665-
hashmap_remove(m->jobs, UINT32_TO_PTR(j->id));
665+
hashmap_remove_value(m->jobs, UINT32_TO_PTR(j->id), j);
666666
job_free(j);
667667
j = installed_job;
668668
}
@@ -683,7 +683,7 @@ static int transaction_apply(
683683
rollback:
684684

685685
HASHMAP_FOREACH(j, tr->jobs)
686-
hashmap_remove(m->jobs, UINT32_TO_PTR(j->id));
686+
hashmap_remove_value(m->jobs, UINT32_TO_PTR(j->id), j);
687687

688688
return r;
689689
}

0 commit comments

Comments
 (0)