summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2012-12-19 12:32:52 +0200
committerPanu Matilainen <pmatilai@redhat.com>2012-12-19 12:47:07 +0200
commitec19a4968274a7ed11f59ca207dca16ce1ebb1d8 (patch)
treedd2eb9c0b55a7e16cd1a381b228740025654fec3
parent90e18d0edb587d26777983fb68168857631e559b (diff)
downloadrpm-ec19a4968274a7ed11f59ca207dca16ce1ebb1d8.tar.gz
rpm-ec19a4968274a7ed11f59ca207dca16ce1ebb1d8.tar.bz2
rpm-ec19a4968274a7ed11f59ca207dca16ce1ebb1d8.zip
Handle transaction global pool allocation centrally in rpmtsPool()
- Previously the pool would only get allocated on successfull addition of install or erasure elements, causing assert() failures on operations on empty transaction set, which should be just a no-op, not an error. - Make rpmtsPool() create the pool if it doesn't exist, update relevant users to call rpmtsPool() instead of directly accessing tsmem->pool, this avoids having to worry about pool existence in all the various cases. - Also fix up the pool-related comment on rpmtsEmpty(): pools does not and can not support emptying as it could break references to its contents. Per-string refcount would be needed for emptying support. (cherry picked from commit d73535e1a9dc5095e78475adc5b636d99f01efa9)
-rw-r--r--lib/depends.c12
-rw-r--r--lib/rpmts.c11
-rw-r--r--lib/rpmts_internal.h2
-rw-r--r--lib/transaction.c7
4 files changed, 16 insertions, 16 deletions
diff --git a/lib/depends.c b/lib/depends.c
index 4cda58722..6539396f1 100644
--- a/lib/depends.c
+++ b/lib/depends.c
@@ -99,10 +99,6 @@ static int removePackage(rpmts ts, Header h, rpmte depends)
return 0;
}
- /* Ensure our pool exists before adding elements */
- if (tsmem->pool == NULL)
- tsmem->pool = rpmstrPoolCreate();
-
p = rpmteNew(ts, h, TR_REMOVED, NULL, NULL);
if (p == NULL)
return 1;
@@ -408,10 +404,6 @@ int rpmtsAddInstallElement(rpmts ts, Header h,
goto exit;
}
- /* Ensure our pool exists before adding elements */
- if (tsmem->pool == NULL)
- tsmem->pool = rpmstrPoolCreate();
-
p = rpmteNew(ts, h, TR_ADDED, key, relocs);
if (p == NULL) {
ec = 1;
@@ -445,7 +437,7 @@ int rpmtsAddInstallElement(rpmts ts, Header h,
}
if (tsmem->addedPackages == NULL) {
- tsmem->addedPackages = rpmalCreate(tsmem->pool, 5, rpmtsFlags(ts),
+ tsmem->addedPackages = rpmalCreate(rpmtsPool(ts), 5, rpmtsFlags(ts),
tscolor, rpmtsPrefColor(ts));
}
rpmalAdd(tsmem->addedPackages, p);
@@ -561,7 +553,7 @@ retry:
*/
if (dsflags & RPMSENSE_RPMLIB) {
if (tsmem->rpmlib == NULL)
- rpmdsRpmlibPool(tsmem->pool, &(tsmem->rpmlib), NULL);
+ rpmdsRpmlibPool(rpmtsPool(ts), &(tsmem->rpmlib), NULL);
if (tsmem->rpmlib != NULL && rpmdsSearch(tsmem->rpmlib, dep) >= 0) {
rpmdsNotify(dep, "(rpmlib provides)", rc);
diff --git a/lib/rpmts.c b/lib/rpmts.c
index 3463ce35c..964273473 100644
--- a/lib/rpmts.c
+++ b/lib/rpmts.c
@@ -586,7 +586,7 @@ void rpmtsEmpty(rpmts ts)
}
tsmem->orderCount = 0;
- /* XXX emptying would be sufficient... */
+ /* The pool cannot be emptied, there might be references to its contents */
tsmem->pool = rpmstrPoolFree(tsmem->pool);
removedHashEmpty(tsmem->removedPackages);
return;
@@ -934,7 +934,14 @@ tsMembers rpmtsMembers(rpmts ts)
rpmstrPool rpmtsPool(rpmts ts)
{
tsMembers tsmem = rpmtsMembers(ts);
- return (tsmem != NULL) ? tsmem->pool : NULL;
+ rpmstrPool tspool = NULL;
+
+ if (tsmem) {
+ if (tsmem->pool == NULL)
+ tsmem->pool = rpmstrPoolCreate();
+ tspool = tsmem->pool;
+ }
+ return tspool;
}
rpmts rpmtsCreate(void)
diff --git a/lib/rpmts_internal.h b/lib/rpmts_internal.h
index a22c89267..d4f25e17e 100644
--- a/lib/rpmts_internal.h
+++ b/lib/rpmts_internal.h
@@ -76,7 +76,7 @@ extern "C" {
#endif
/** \ingroup rpmts
- * Return transaction global string pool handle
+ * Return transaction global string pool handle, creating the pool if needed.
* @param ts transaction set
* @return string pool handle (weak ref)
*/
diff --git a/lib/transaction.c b/lib/transaction.c
index 31c847eb8..4cd67207c 100644
--- a/lib/transaction.c
+++ b/lib/transaction.c
@@ -910,6 +910,7 @@ static
rpmdbMatchIterator rpmFindBaseNamesInDB(rpmts ts, uint64_t fileCount)
{
tsMembers tsmem = rpmtsMembers(ts);
+ rpmstrPool tspool = rpmtsPool(ts);
rpmtsi pi; rpmte p;
rpmfi fi;
rpmdbMatchIterator mi;
@@ -938,8 +939,8 @@ rpmdbMatchIterator rpmFindBaseNamesInDB(rpmts ts, uint64_t fileCount)
if (rpmStringSetHasEntry(baseNames, baseNameId))
continue;
- keylen = rpmstrPoolStrlen(tsmem->pool, baseNameId);
- baseName = rpmstrPoolStr(tsmem->pool, baseNameId);
+ keylen = rpmstrPoolStrlen(tspool, baseNameId);
+ baseName = rpmstrPoolStr(tspool, baseNameId);
if (keylen == 0)
keylen++; /* XXX "/" fixup. */
rpmdbExtendIterator(mi, baseName, keylen);
@@ -1311,7 +1312,7 @@ static int rpmtsPrepare(rpmts ts)
const char *dbhome = NULL;
struct stat dbstat;
- fingerPrintCache fpc = fpCacheCreate(fileCount/2 + 10001, tsmem->pool);
+ fingerPrintCache fpc = fpCacheCreate(fileCount/2 + 10001, rpmtsPool(ts));
rpmlog(RPMLOG_DEBUG, "computing %" PRIu64 " file fingerprints\n", fileCount);