[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: librpm / corrupt free list in an FD_t (help please)



On Tue, Jan 14, 2003 at 02:34:27PM -0500, Tristan Van Berkom wrote:
> Is this good practice to loop through the
> installed packages in the db ?
> 
> ===========================================================================
>     if (rpmdbOpen ("/", &db, O_RDONLY, 0) == 0) {
>         if ((iter = rpmdbInitIterator(db, RPMDBI_PACKAGES,
> 				  NULL, 0)) != NULL) {

Do
	ts = rpmtsCreate()
	iter = rpmtsInitIterator(ts, RPMDBI_PACKAGES, NULL, 0)
instead please. The rationale is that there's now a fair amount
of state associated with a dbenv that user applications are poorly
equipped to deal with, so an rpmdb object is being removed from the
rpmlib API.

Yes, there's still a database, but there are lazy opens of indices when
needed, a conversion from O_RDONLY -> O_RDWR buried in rpmtsRun(),
signal handlers triggered by dbiOpen, refcounts, exits, more, that need
doing if you go after the rpmdb API directly.

Basically, you don't want to messing with an rpmdb if you can avoid.

Yes, there is only rpmtsInitIterator() ATM, use rpmdbNextIterator() et al
methods until I get a chance to add rpmtsFoo() wrappers for rpmdbFoo() methods.

> 	    while (h = rpmdbNextIterator(iter)) {
> 	 	// get desired info on installed package ...
> 		headerGetEntry(...h...);
> 	    }
> 	    iter = rpmdbFreeIterator(iter);
> 	}
> 	if (rpmdbClose(db)) {
> 	    /* I have big problems ? */
> 	}

Here would be instead
	ts = rpmtsFree(ts);
which would close the refcounted database as side effect.

73 de Jeff

-- 
Jeff Johnson	ARS N3NPQ
jbj@redhat.com (jbj@jbj.org)
Chapel Hill, NC





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] []