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: 19-Mar-2009 19:22:04 Branch: HEAD Handle: 2009031918220300 Modified files: rpm CHANGES rpm/lib librpm.vers poptALL.c psm.c psm.h Log: - yarn: convert psm refcount to usage mutex. Summary: Revision Changes Path 1.2848 +1 -0 rpm/CHANGES 1.61 +0 -6 rpm/lib/librpm.vers 2.113 +4 -0 rpm/lib/poptALL.c 2.346 +38 -44 rpm/lib/psm.c 2.69 +8 -20 rpm/lib/psm.h ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/CHANGES ============================================================================ $ cvs diff -u -r1.2847 -r1.2848 CHANGES --- rpm/CHANGES 19 Mar 2009 17:33:43 -0000 1.2847 +++ rpm/CHANGES 19 Mar 2009 18:22:03 -0000 1.2848 @@ -1,5 +1,6 @@ 5.2a3 -> 5.2a4: + - jbj: yarn: convert psm refcount to usage mutex. - jbj: yarn: convert rpmxar refcount to usage mutex. - jbj: yarn: convert pgpDig refcount to usage mutex (avoid recurse deadlock). - jbj: yarn: convert rpmts refcount to usage mutex (avoid recurse deadlock). @@ . patch -p0 <<'@@ .' Index: rpm/lib/librpm.vers ============================================================================ $ cvs diff -u -r1.60 -r1.61 librpm.vers --- rpm/lib/librpm.vers 19 Mar 2009 14:57:21 -0000 1.60 +++ rpm/lib/librpm.vers 19 Mar 2009 18:22:03 -0000 1.61 @@ -404,12 +404,6 @@ showVerifyPackage; specedit; strict_erasures; - _tar_debug; - tarHeaderRead; - tarHeaderWrite; - tarTrailerWrite; - XrpmpsmLink; - XrpmpsmUnlink; XrpmtsiFree; XrpmtsiInit; local: @@ . patch -p0 <<'@@ .' Index: rpm/lib/poptALL.c ============================================================================ $ cvs diff -u -r2.112 -r2.113 poptALL.c --- rpm/lib/poptALL.c 19 Mar 2009 14:57:21 -0000 2.112 +++ rpm/lib/poptALL.c 19 Mar 2009 18:22:03 -0000 2.113 @@ -78,6 +78,8 @@ /*...@unchecked@*/ extern int _psm_debug; +/*...@unchecked@*/ +extern rpmioPool _psmPool; /*...@unchecked@*/ extern int _psm_threads; @@ -466,7 +468,9 @@ _rpmgiPool = rpmioFreePool(_rpmgiPool); + _psmPool = rpmioFreePool(_psmPool); _rpmtsiPool = rpmioFreePool(_rpmtsiPool); + _rpmtsPool = rpmioFreePool(_rpmtsPool); _rpmtePool = rpmioFreePool(_rpmtePool); _rpmpsPool = rpmioFreePool(_rpmpsPool); @@ . patch -p0 <<'@@ .' Index: rpm/lib/psm.c ============================================================================ $ cvs diff -u -r2.345 -r2.346 psm.c --- rpm/lib/psm.c 14 Mar 2009 23:46:19 -0000 2.345 +++ rpm/lib/psm.c 19 Mar 2009 18:22:03 -0000 2.346 @@ -61,6 +61,21 @@ /*...@access rpmluav @*/ +/*...@unchecked@*/ /*...@null@*/ +rpmioPool _psmPool; + +static rpmpsm rpmpsmGetPool(/*...@null@*/ rpmioPool pool) + /*...@modifies pool @*/ +{ + rpmpsm psm; + + if (_psmPool == NULL) { + _psmPool = rpmioNewPool("psm", sizeof(*psm), -1, _psm_debug); + pool = _psmPool; + } + return (rpmpsm) rpmioGetPool(pool, sizeof(*psm)); +} + /** * Mark files in database shared with this package as "replaced". * @param psm package state machine data @@ -1535,62 +1550,41 @@ /*...@noteached@*/ } -rpmpsm XrpmpsmUnlink(rpmpsm psm, const char * msg, const char * fn, unsigned ln) +rpmpsm rpmpsmFree(rpmpsm psm) { - if (psm == NULL) return NULL; -/*...@-modfilesys@*/ -if (_psm_debug && msg != NULL) -fprintf(stderr, "--> psm %p -- %d %s at %s:%u\n", psm, psm->nrefs, msg, fn, ln); -/*...@=modfilesys@*/ - psm->nrefs--; - return NULL; -} + static const char msg[] = "rpmpsmFree"; + if (psm == NULL) + return NULL; -rpmpsm XrpmpsmLink(rpmpsm psm, const char * msg, const char * fn, unsigned ln) -{ - if (psm == NULL) return NULL; - psm->nrefs++; + yarnPossess(psm->use); /*...@-modfilesys@*/ -if (_psm_debug && msg != NULL) -fprintf(stderr, "--> psm %p ++ %d %s at %s:%u\n", psm, psm->nrefs, msg, fn, ln); +if (_psm_debug) +fprintf(stderr, "--> psm %p -- %ld %s at %s:%u\n", psm, yarnPeekLock(psm->use), msg, __FILE__, __LINE__); /*...@=modfilesys@*/ - /*...@-refcounttrans@*/ return psm; /*...@=refcounttrans@*/ -} - -rpmpsm rpmpsmFree(rpmpsm psm) -{ - const char * msg = "rpmpsmFree"; - if (psm == NULL) - return NULL; - - if (psm->nrefs > 1) - return rpmpsmUnlink(psm, msg); + if (yarnPeekLock(psm->use) <= 1L) { /*...@-nullstate@*/ - psm->fi = rpmfiFree(psm->fi); + psm->fi = rpmfiFree(psm->fi); #ifdef NOTYET - psm->te = rpmteFree(psm->te); + psm->te = rpmteFree(psm->te); #else - psm->te = NULL; + psm->te = NULL; #endif /*...@-internalglobs@*/ - psm->ts = rpmtsFree(psm->ts); + psm->ts = rpmtsFree(psm->ts); /*...@=internalglobs@*/ - psm->sstates = _free(psm->sstates); - psm->IPhe->p.ptr = _free(psm->IPhe->p.ptr); - psm->IPhe = _free(psm->IPhe); - psm->NVRA = _free(psm->NVRA); - psm->triggers = rpmdsFree(psm->triggers); - - (void) rpmpsmUnlink(psm, msg); - - /*...@-refcounttrans -userelea...@*/ - memset(psm, 0, sizeof(*psm)); /* XXX trash and burn */ - psm = _free(psm); - /*...@=refcounttrans =userelea...@*/ + psm->sstates = _free(psm->sstates); + psm->IPhe->p.ptr = _free(psm->IPhe->p.ptr); + psm->IPhe = _free(psm->IPhe); + psm->NVRA = _free(psm->NVRA); + psm->triggers = rpmdsFree(psm->triggers); + + psm = (rpmpsm) rpmioPutPool((rpmioItem)psm); + } else + yarnTwist(psm->use, BY, -1); return NULL; /*...@=nullstate@*/ @@ -1598,8 +1592,8 @@ rpmpsm rpmpsmNew(rpmts ts, rpmte te, rpmfi fi) { - const char * msg = "rpmpsmNew"; - rpmpsm psm = xcalloc(1, sizeof(*psm)); + static const char msg[] = "rpmpsmNew"; + rpmpsm psm = rpmpsmGetPool(_psmPool); if (ts) psm->ts = rpmtsLink(ts, msg); #ifdef NOTYET @@ . patch -p0 <<'@@ .' Index: rpm/lib/psm.h ============================================================================ $ cvs diff -u -r2.68 -r2.69 psm.h --- rpm/lib/psm.h 15 Oct 2008 05:27:23 -0000 2.68 +++ rpm/lib/psm.h 19 Mar 2009 18:22:03 -0000 2.69 @@ -113,6 +113,10 @@ /** */ struct rpmpsm_s { + yarnLock use; /*!< use count -- return to pool when zero */ +/*...@shared@*/ /*...@null@*/ + void *pool; /*!< pool (or NULL if malloc'd) */ + struct rpmsqElem sq; /*!< Scriptlet/signal queue element. */ /*...@only@*/ /*...@null@*/ @@ -169,8 +173,6 @@ pkgStage stage; /*!< Current psm stage. */ pkgStage nstage; /*!< Next psm stage. */ -/*...@refs@*/ - int nrefs; /*!< Reference count. */ }; #ifdef __cplusplus @@ -187,15 +189,8 @@ rpmpsm rpmpsmUnlink (/*...@killref@*/ /*...@only@*/ /*...@null@*/ rpmpsm psm, /*...@null@*/ const char * msg) /*...@modifies psm @*/; - -/** @todo Remove debugging entry from the ABI. */ -/*...@-exportlocal@*/ -/*...@null@*/ -rpmpsm XrpmpsmUnlink (/*...@killref@*/ /*...@only@*/ /*...@null@*/ rpmpsm psm, - /*...@null@*/ const char * msg, const char * fn, unsigned ln) - /*...@modifies psm @*/; -/*...@=exportlocal@*/ -#define rpmpsmUnlink(_psm, _msg) XrpmpsmUnlink(_psm, _msg, __FILE__, __LINE__) +#define rpmpsmUnlink(_psm, _msg) \ + ((rpmpsm)rpmioUnlinkPoolItem((rpmioItem)(_psm), _msg, __FILE__, __LINE__)) /** * Reference a package state machine instance. @@ -206,15 +201,8 @@ /*...@unused@*/ /*...@newref@*/ /*...@null@*/ rpmpsm rpmpsmLink (/*...@null@*/ rpmpsm psm, /*...@null@*/ const char * msg) /*...@modifies psm @*/; - -/** @todo Remove debugging entry from the ABI. */ -/*...@-exportlocal@*/ -/*...@newref@*/ /*...@null@*/ -rpmpsm XrpmpsmLink (/*...@null@*/ rpmpsm psm, /*...@null@*/ const char * msg, - const char * fn, unsigned ln) - /*...@modifies psm @*/; -/*...@=exportlocal@*/ -#define rpmpsmLink(_psm, _msg) XrpmpsmLink(_psm, _msg, __FILE__, __LINE__) +#define rpmpsmLink(_psm, _msg) \ + ((rpmpsm)rpmioLinkPoolItem((rpmioItem)(_psm), _msg, __FILE__, __LINE__)) /** * Destroy a package state machine. @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org