- 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)
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;
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;
}
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);
*/
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);
}
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;
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)
#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)
*/
rpmdbMatchIterator rpmFindBaseNamesInDB(rpmts ts, uint64_t fileCount)
{
tsMembers tsmem = rpmtsMembers(ts);
+ rpmstrPool tspool = rpmtsPool(ts);
rpmtsi pi; rpmte p;
rpmfi fi;
rpmdbMatchIterator mi;
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);
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);