2011/2/14 Per Øyvind Karlsen <pkarl...@rpm5.org>: > 2011/2/14 Jeff Johnson <n3...@mac.com>: >> >> On Feb 13, 2011, at 9:41 PM, Per Øyvind Karlsen wrote: >> >>> 2011/2/14 Jeff Johnson <n3...@mac.com>: >>>> Hmmm ... rpmmiCount is supposed to be invoked lazily when needed, >>>> not as part of every iteration. >>>> >>>> The conditions in rpmmiCount() may need adjustment. That I can >>>> easily believe. >>> in lib/psm.c:1666 >>> >>> rpmmiCount() is used, where rpmmiNext() has already created mi->mi_dbc >>> without mi->mi_count being set. >>> >> >> OK. >> >> So move rpmmiCount() out of the iteration loop in psm.c:1666 instead of >> muck about in rpmmiNext() is what I would try. > I tried that first, but that resulted in some deadlock for which I could only > kill rpm with -SIGKILL... Would this patch be better? :)
-- Regards, Per Øyvind
--- rpm-5.3.8/rpmdb/rpmdb.c.rpmmi_next~ 2011-02-15 22:24:26.690003947 +0100 +++ rpm-5.3.8/rpmdb/rpmdb.c 2011-02-16 15:19:28.830004006 +0100 @@ -1630,22 +1630,26 @@ fprintf(stderr, "<-- %s(%p) rc %u\n", __ unsigned int rpmmiCount(rpmmi mi) { unsigned int rc; + int initDbc; /* XXX Secondary db associated with Packages needs cursor record count */ - if (mi && mi->mi_primary && mi->mi_dbc == NULL) { + if (mi && mi->mi_primary && ((initDbc = mi->mi_dbc == NULL) || mi->mi_count == 0)) { dbiIndex dbi = dbiOpen(mi->mi_db, mi->mi_rpmtag, 0); DBT k = DBT_INIT; DBT v = DBT_INIT; int xx; + if(initDbc) { assert(dbi != NULL); /* XXX dbiCopen doesn't handle dbi == NULL */ - xx = dbiCopen(dbi, dbiTxnid(dbi), &mi->mi_dbc, mi->mi_cflags); + xx = dbiCopen(dbi, dbiTxnid(dbi), &mi->mi_dbc, mi->mi_cflags); + } k.data = mi->mi_keyp; k.size = (u_int32_t)mi->mi_keylen; if (k.data && k.size == 0) k.size = (UINT32_T) strlen((char *)k.data); if (k.data && k.size == 0) k.size++; /* XXX "/" fixup. */ if (!dbiGet(dbi, mi->mi_dbc, &k, &v, DB_SET)) xx = dbiCount(dbi, mi->mi_dbc, &mi->mi_count, 0); - mi->mi_dbc = NULL; + if(initDbc) + mi->mi_dbc = NULL; } rc = (mi ? mi->mi_count : 0);