summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2022-02-02 13:46:23 +0200
committerMichal Domonkos <mdomonko@redhat.com>2022-07-01 10:52:14 +0200
commita63276efdafcb2ddc513f9c33ad0671a73f6c855 (patch)
tree6cc113ef78a5d4b286687d7f33a31a0f7d833809
parent1db8004b3bcbf073257b4a059915001d512e0686 (diff)
downloadrpm-a63276efdafcb2ddc513f9c33ad0671a73f6c855.tar.gz
Really fix spurious %transfiletriggerpostun execution (RhBug:2023311)
Commit b3d672a5523dfec033160e5cc866432a0e808649 got the base reasoning in the ballpark but the code all wrong, introducing a severe performance regression without actually fixing what it claimed to. The missing incredient is actually comparing the current prefix with the triggers in matched package (trying to describe this makes my head spin): a package may have multiple triggers on multiple prefixes and we need to make sure we only execute triggers of this type, from this prefix. This stuff really needs more and better testcases. Fixes: b3d672a5523dfec033160e5cc866432a0e808649 (cherry picked from commit 0988ccb53abf426587d228df5c60c4042da71999)
-rw-r--r--lib/rpmtriggers.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/rpmtriggers.c b/lib/rpmtriggers.c
index 6fe4db65d..3f8fa22d0 100644
--- a/lib/rpmtriggers.c
+++ b/lib/rpmtriggers.c
@@ -97,14 +97,16 @@ static void rpmtriggersSortAndUniq(rpmtriggers trigs)
}
}
-static void addTriggers(rpmts ts, Header trigH, rpmsenseFlags filter)
+static void addTriggers(rpmts ts, Header trigH, rpmsenseFlags filter,
+ const char *prefix)
{
int tix = 0;
rpmds ds;
rpmds triggers = rpmdsNew(trigH, RPMTAG_TRANSFILETRIGGERNAME, 0);
while ((ds = rpmdsFilterTi(triggers, tix))) {
- if ((rpmdsNext(ds) >= 0) && (rpmdsFlags(ds) & filter)) {
+ if ((rpmdsNext(ds) >= 0) && (rpmdsFlags(ds) & filter) &&
+ strcmp(prefix, rpmdsN(ds)) == 0) {
struct rpmtd_s priorities;
if (headerGet(trigH, RPMTAG_TRANSFILETRIGGERPRIORITIES,
@@ -141,12 +143,13 @@ void rpmtriggersPrepPostUnTransFileTrigs(rpmts ts, rpmte te)
if (RPMFILE_IS_INSTALLED(rpmfiFState(fi))) {
unsigned int npkg = rpmdbIndexIteratorNumPkgs(ii);
const unsigned int *offs = rpmdbIndexIteratorPkgOffsets(ii);
- /* Save any matching postun triggers */
+ /* Save any postun triggers matching this prefix */
for (int i = 0; i < npkg; i++) {
Header h = rpmdbGetHeaderAt(rpmtsGetRdb(ts), offs[i]);
- addTriggers(ts, h, RPMSENSE_TRIGGERPOSTUN);
+ addTriggers(ts, h, RPMSENSE_TRIGGERPOSTUN, pfx);
headerFree(h);
}
+ break;
}
}
rpmfiFree(fi);