RPM Package Manager, CVS Repository http://rpm5.org/cvs/ ____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: j...@rpm5.org Module: rpm Date: 18-Mar-2009 20:59:50 Branch: HEAD Handle: 2009031819595000 Modified files: rpm CHANGES rpm/lib librpm.vers poptALL.c rpmgi.c rpmgi.h Log: - yarn: convert rpmgi refcount to usage mutex. Summary: Revision Changes Path 1.2836 +1 -0 rpm/CHANGES 1.57 +0 -2 rpm/lib/librpm.vers 2.107 +5 -2 rpm/lib/poptALL.c 2.57 +42 -53 rpm/lib/rpmgi.c 2.28 +8 -20 rpm/lib/rpmgi.h ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/CHANGES ============================================================================ $ cvs diff -u -r1.2835 -r1.2836 CHANGES --- rpm/CHANGES 18 Mar 2009 18:36:36 -0000 1.2835 +++ rpm/CHANGES 18 Mar 2009 19:59:50 -0000 1.2836 @@ -1,5 +1,6 @@ 5.2a3 -> 5.2a4: + - jbj: yarn: convert rpmgi refcount to usage mutex. - jbj: yarn: use the pool changes where possible. - jbj: yarn: add generic Link/Unlink refcount diddlers. - jbj: yarn: add debugging, reuse counter, and zlog to rpmioPool. @@ . patch -p0 <<'@@ .' Index: rpm/lib/librpm.vers ============================================================================ $ cvs diff -u -r1.56 -r1.57 librpm.vers --- rpm/lib/librpm.vers 18 Mar 2009 18:52:34 -0000 1.56 +++ rpm/lib/librpm.vers 18 Mar 2009 19:59:50 -0000 1.57 @@ -408,8 +408,6 @@ tarHeaderRead; tarHeaderWrite; tarTrailerWrite; - XrpmgiLink; - XrpmgiUnlink; XrpmpsLink; XrpmpsmLink; XrpmpsmUnlink; @@ . patch -p0 <<'@@ .' Index: rpm/lib/poptALL.c ============================================================================ $ cvs diff -u -r2.106 -r2.107 poptALL.c --- rpm/lib/poptALL.c 17 Mar 2009 23:59:02 -0000 2.106 +++ rpm/lib/poptALL.c 18 Mar 2009 19:59:50 -0000 2.107 @@ -102,9 +102,10 @@ /*...@unchecked@*/ extern rpmioPool _rpmfiPool; - /*...@unchecked@*/ extern int _rpmgi_debug; +/*...@unchecked@*/ +extern rpmioPool _rpmgiPool; /*...@unchecked@*/ extern int _rpmps_debug; @@ -453,9 +454,11 @@ { extern rpmioPool _headerPool; - _headerPool = rpmioFreePool(_headerPool); + _rpmgiPool = rpmioFreePool(_rpmgiPool); + _rpmdsPool = rpmioFreePool(_rpmdsPool); _rpmfiPool = rpmioFreePool(_rpmfiPool); + _headerPool = rpmioFreePool(_headerPool); /* XXX this should be done in the rpmioClean() wrapper. */ /* keeps memory leak checkers quiet */ @@ . patch -p0 <<'@@ .' Index: rpm/lib/rpmgi.c ============================================================================ $ cvs diff -u -r2.56 -r2.57 rpmgi.c --- rpm/lib/rpmgi.c 8 Dec 2008 07:51:02 -0000 2.56 +++ rpm/lib/rpmgi.c 18 Mar 2009 19:59:50 -0000 2.57 @@ -41,6 +41,21 @@ /*...@unchecked@*/ rpmgiFlags giFlags = RPMGI_NONE; +/*...@unchecked@*/ /*...@null@*/ +rpmioPool _rpmgiPool; + +static rpmgi rpmgiGetPool(/*...@null@*/ rpmioPool pool) + /*...@modifies pool @*/ +{ + rpmgi gi; + + if (_rpmgiPool == NULL) { + _rpmgiPool = rpmioNewPool("gi", sizeof(*gi), -1, _rpmgi_debug); + pool = _rpmgiPool; + } + return (rpmgi) rpmioGetPool(pool, sizeof(*gi)); +} + /** */ /*...@unchecked@*/ @@ -452,72 +467,46 @@ return rpmrc; } -rpmgi XrpmgiUnlink(rpmgi gi, const char * msg, const char * fn, unsigned ln) -{ - if (gi == NULL) return NULL; - -if (_rpmgi_debug && msg != NULL) -fprintf(stderr, "--> gi %p -- %d %s(%s) at %s:%u\n", gi, gi->nrefs, msg, tagName(gi->tag), fn, ln); - - gi->nrefs--; - return NULL; -} - -rpmgi XrpmgiLink(rpmgi gi, const char * msg, const char * fn, unsigned ln) -{ - if (gi == NULL) return NULL; - gi->nrefs++; - -if (_rpmgi_debug && msg != NULL) -fprintf(stderr, "--> gi %p ++ %d %s(%s) at %s:%u\n", gi, gi->nrefs, msg, tagName(gi->tag), fn, ln); - - /*...@-refcounttrans@*/ return gi; /*...@=refcounttrans@*/ -} - rpmgi rpmgiFree(rpmgi gi) { - if (gi == NULL) - return NULL; + int xx; - if (gi->nrefs > 1) - return rpmgiUnlink(gi, "rpmgiFree"); + if (gi == NULL) return NULL; - (void) rpmgiUnlink(gi, "rpmgiFree"); + yarnPossess(gi->use); +if (_rpmgi_debug) +fprintf(stderr, "--> gi %p -- %ld %s(%s) at %s:%u\n", gi, yarnPeekLock(gi->use), "rpmgiFree", tagName(gi->tag), __FILE__, __LINE__); + if (yarnPeekLock(gi->use) <= 1L) { + gi->hdrPath = _free(gi->hdrPath); + gi->h = headerFree(gi->h); -/*...@-usereleased@*/ + gi->argv = argvFree(gi->argv); - gi->hdrPath = _free(gi->hdrPath); - gi->h = headerFree(gi->h); - - gi->argv = argvFree(gi->argv); + if (gi->ftsp != NULL) { + xx = Fts_close(gi->ftsp); + gi->ftsp = NULL; + gi->fts = NULL; + } + if (gi->fd != NULL) { + xx = Fclose(gi->fd); + gi->fd = NULL; + } + gi->tsi = rpmtsiFree(gi->tsi); + gi->mi = rpmdbFreeIterator(gi->mi); + gi->ts = rpmtsFree(gi->ts); + + gi = (rpmgi) rpmioPutPool((rpmioItem)gi); + } else + yarnTwist(gi->use, BY, -1); - if (gi->ftsp != NULL) { - int xx; - xx = Fts_close(gi->ftsp); - gi->ftsp = NULL; - gi->fts = NULL; - } - if (gi->fd != NULL) { - (void) Fclose(gi->fd); - gi->fd = NULL; - } - gi->tsi = rpmtsiFree(gi->tsi); - gi->mi = rpmdbFreeIterator(gi->mi); - gi->ts = rpmtsFree(gi->ts); - - memset(gi, 0, sizeof(*gi)); /* XXX trash and burn */ -/*...@-refcounttrans@*/ - gi = _free(gi); -/*...@=refcounttrans@*/ -/*...@=usereleased@*/ return NULL; } rpmgi rpmgiNew(rpmts ts, int tag, const void * keyp, size_t keylen) { - rpmgi gi = xcalloc(1, sizeof(*gi)); + rpmgi gi = rpmgiGetPool(_rpmgiPool); - if (gi == NULL) + if (gi == NULL) /* XXX can't happen */ return NULL; gi->ts = rpmtsLink(ts, "rpmgiNew"); @@ . patch -p0 <<'@@ .' Index: rpm/lib/rpmgi.h ============================================================================ $ cvs diff -u -r2.27 -r2.28 rpmgi.h --- rpm/lib/rpmgi.h 30 Jul 2008 22:14:32 -0000 2.27 +++ rpm/lib/rpmgi.h 18 Mar 2009 19:59:50 -0000 2.28 @@ -40,6 +40,10 @@ /** \ingroup rpmgi */ struct rpmgi_s { + yarnLock use; /*!< use count -- return to pool when zero */ +/*...@shared@*/ /*...@null@*/ + void *pool; /*!< pool (or NULL if malloc'd) */ + /*...@refcounted@*/ rpmts ts; /*!< Iterator transaction set. */ int (*tsOrder) (rpmts ts); /*!< Iterator transaction ordering. */ @@ -78,8 +82,6 @@ /*...@null@*/ rpmRC (*stash) (rpmgi gi, Header h); -/*...@refs@*/ - int nrefs; /*!< Reference count. */ }; #endif @@ -100,15 +102,8 @@ rpmgi rpmgiUnlink (/*...@killref@*/ /*...@only@*/ /*...@null@*/ rpmgi gi, /*...@null@*/ const char * msg) /*...@modifies gi @*/; - -/** @todo Remove debugging entry from the ABI. */ -/*...@-exportlocal@*/ -/*...@null@*/ -rpmgi XrpmgiUnlink (/*...@killref@*/ /*...@only@*/ /*...@null@*/ rpmgi gi, - /*...@null@*/ const char * msg, const char * fn, unsigned ln) - /*...@modifies gi @*/; -/*...@=exportlocal@*/ -#define rpmgiUnlink(_gi, _msg) XrpmgiUnlink(_gi, _msg, __FILE__, __LINE__) +#define rpmgiUnlink(_gi, _msg) \ + ((rpmgi)rpmioUnlinkPoolItem((rpmioItem)(_gi), _msg, __FILE__, __LINE__)) /** * Reference a generalized iterator instance. @@ -119,15 +114,8 @@ /*...@unused@*/ /*...@newref@*/ /*...@null@*/ rpmgi rpmgiLink (/*...@null@*/ rpmgi gi, /*...@null@*/ const char * msg) /*...@modifies gi @*/; - -/** @todo Remove debugging entry from the ABI. */ -/*...@-exportlocal@*/ -/*...@newref@*/ /*...@null@*/ -rpmgi XrpmgiLink (/*...@null@*/ rpmgi gi, /*...@null@*/ const char * msg, - const char * fn, unsigned ln) - /*...@modifies gi @*/; -/*...@=exportlocal@*/ -#define rpmgiLink(_gi, _msg) XrpmgiLink(_gi, _msg, __FILE__, __LINE__) +#define rpmgiLink(_gi, _msg) \ + ((rpmgi)rpmioLinkPoolItem((rpmioItem)(_gi), _msg, __FILE__, __LINE__)) /** Destroy a generalized iterator. * @param gi generalized iterator @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org