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 15:57:21 Branch: HEAD Handle: 2009031914572001 Modified files: rpm CHANGES rpm/lib librpm.vers poptALL.c rpmts.c rpmts.h Log: - yarn: convert rpmts refcount to usage mutex (avoid recurse deadlock). Summary: Revision Changes Path 1.2845 +1 -0 rpm/CHANGES 1.60 +0 -2 rpm/lib/librpm.vers 2.112 +3 -0 rpm/lib/poptALL.c 2.159 +60 -55 rpm/lib/rpmts.c 2.110 +9 -18 rpm/lib/rpmts.h ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/CHANGES ============================================================================ $ cvs diff -u -r1.2844 -r1.2845 CHANGES --- rpm/CHANGES 19 Mar 2009 14:52:38 -0000 1.2844 +++ rpm/CHANGES 19 Mar 2009 14:57:20 -0000 1.2845 @@ -1,5 +1,6 @@ 5.2a3 -> 5.2a4: + - jbj: yarn: convert rpmts refcount to usage mutex (avoid recurse deadlock). - jbj: rpmps: fix: avoid reusing items from pool for now. - proyvind: libcpuinfo may now return 64bit feature only if PER_LINUX_32BIT personality isn't set, so don't check un.machine anymore. @@ . patch -p0 <<'@@ .' Index: rpm/lib/librpm.vers ============================================================================ $ cvs diff -u -r1.59 -r1.60 librpm.vers --- rpm/lib/librpm.vers 18 Mar 2009 22:58:33 -0000 1.59 +++ rpm/lib/librpm.vers 19 Mar 2009 14:57:21 -0000 1.60 @@ -412,8 +412,6 @@ XrpmpsmUnlink; XrpmtsiFree; XrpmtsiInit; - XrpmtsLink; - XrpmtsUnlink; local: *; }; @@ . patch -p0 <<'@@ .' Index: rpm/lib/poptALL.c ============================================================================ $ cvs diff -u -r2.111 -r2.112 poptALL.c --- rpm/lib/poptALL.c 18 Mar 2009 23:23:56 -0000 2.111 +++ rpm/lib/poptALL.c 19 Mar 2009 14:57:21 -0000 2.112 @@ -129,6 +129,8 @@ /*...@unchecked@*/ extern int _rpmts_debug; +/*...@unchecked@*/ +extern rpmioPool _rpmtsPool; /*...@unchecked@*/ extern int _rpmwf_debug; @@ -465,6 +467,7 @@ _rpmgiPool = rpmioFreePool(_rpmgiPool); _rpmtsiPool = rpmioFreePool(_rpmtsiPool); + _rpmtsPool = rpmioFreePool(_rpmtsPool); _rpmtePool = rpmioFreePool(_rpmtePool); _rpmpsPool = rpmioFreePool(_rpmpsPool); @@ . patch -p0 <<'@@ .' Index: rpm/lib/rpmts.c ============================================================================ $ cvs diff -u -r2.158 -r2.159 rpmts.c --- rpm/lib/rpmts.c 10 Dec 2008 23:08:27 -0000 2.158 +++ rpm/lib/rpmts.c 19 Mar 2009 14:57:21 -0000 2.159 @@ -88,26 +88,23 @@ /*...@unchecked@*/ int _rpmts_macros = 0; -rpmts XrpmtsUnlink(rpmts ts, const char * msg, const char * fn, unsigned ln) -{ -/*...@-modfilesys@*/ -if (_rpmts_debug) -fprintf(stderr, "--> ts %p -- %d %s at %s:%u\n", ts, ts->nrefs, msg, fn, ln); -/*...@=modfilesys@*/ - ts->nrefs--; - return NULL; -} -rpmts XrpmtsLink(rpmts ts, const char * msg, const char * fn, unsigned ln) +/*...@unchecked@*/ /*...@null@*/ +rpmioPool _rpmtsPool; + +static rpmts rpmtsGetPool(/*...@null@*/ rpmioPool pool) + /*...@modifies pool @*/ { - ts->nrefs++; -/*...@-modfilesys@*/ -if (_rpmts_debug) -fprintf(stderr, "--> ts %p ++ %d %s at %s:%u\n", ts, ts->nrefs, msg, fn, ln); -/*...@=modfilesys@*/ - /*...@-refcounttrans@*/ return ts; /*...@=refcounttrans@*/ + rpmts ts; + + if (_rpmtsPool == NULL) { + _rpmtsPool = rpmioNewPool("ts", sizeof(*ts), -1, _rpmts_debug); + pool = _rpmtsPool; + } + return (rpmts) rpmioGetPool(pool, sizeof(*ts)); } + int rpmtsCloseDB(rpmts ts) { int rc = 0; @@ -642,64 +639,75 @@ if (ts == NULL) return NULL; - if (ts->nrefs > 1) - return rpmtsUnlink(ts, "tsCreate"); + yarnPossess(ts->use); +/*...@-modfilesys@*/ +if (_rpmts_debug) +fprintf(stderr, "--> ts %p -- %ld %s at %s:%u\n", ts, yarnPeekLock(ts->use), "tsCreate", __FILE__, __LINE__); +/*...@=modfilesys@*/ + + if (yarnPeekLock(ts->use) <= 1L) { /*...@-nullstate@*/ /* FIX: partial annotations */ - rpmtsEmpty(ts); + /* XXX there's a recursion here ... release and reacquire the lock */ +#ifndef BUGGY + yarnRelease(ts->use); /* XXX hack-o-round */ +#endif + rpmtsEmpty(ts); +#ifndef BUGGY + yarnPossess(ts->use); /* XXX hack-o-round */ +#endif /*...@=nullstate@*/ - ts->PRCO = rpmdsFreePRCO(ts->PRCO); + ts->PRCO = rpmdsFreePRCO(ts->PRCO); - (void) rpmtsCloseDB(ts); + (void) rpmtsCloseDB(ts); - (void) rpmtsCloseSDB(ts); + (void) rpmtsCloseSDB(ts); - ts->sx = rpmsxFree(ts->sx); + ts->sx = rpmsxFree(ts->sx); - ts->removedPackages = _free(ts->removedPackages); + ts->removedPackages = _free(ts->removedPackages); - ts->availablePackages = rpmalFree(ts->availablePackages); - ts->numAvailablePackages = 0; + ts->availablePackages = rpmalFree(ts->availablePackages); + ts->numAvailablePackages = 0; - ts->dsi = _free(ts->dsi); + ts->dsi = _free(ts->dsi); - if (ts->scriptFd != NULL) { + if (ts->scriptFd != NULL) { /*...@-refcounttrans@*/ /* FIX: XfdFree annotation */ - ts->scriptFd = fdFree(ts->scriptFd, "rpmtsFree"); + ts->scriptFd = fdFree(ts->scriptFd, "rpmtsFree"); /*...@=refcounttrans@*/ - ts->scriptFd = NULL; - } - ts->rootDir = _free(ts->rootDir); - ts->currDir = _free(ts->currDir); + ts->scriptFd = NULL; + } + ts->rootDir = _free(ts->rootDir); + ts->currDir = _free(ts->currDir); /*...@-type +voidabstract @*/ /* FIX: double indirection */ - ts->order = _free(ts->order); + ts->order = _free(ts->order); /*...@=type =voidabstract @*/ - ts->orderAlloced = 0; + ts->orderAlloced = 0; - ts->keyring = rpmKeyringFree(ts->keyring); - ts->pkpkt = _free(ts->pkpkt); - ts->pkpktlen = 0; - memset(ts->pksignid, 0, sizeof(ts->pksignid)); + ts->keyring = rpmKeyringFree(ts->keyring); + ts->pkpkt = _free(ts->pkpkt); + ts->pkpktlen = 0; + memset(ts->pksignid, 0, sizeof(ts->pksignid)); - if (_rpmts_stats) - rpmtsPrintStats(ts); + if (_rpmts_stats) + rpmtsPrintStats(ts); - if (_rpmts_macros) { - const char ** av = NULL; + if (_rpmts_macros) { + const char ** av = NULL; /*...@-globs@*/ /* Avoid rpmGlobalMcroContext et al. */ - (void)rpmGetMacroEntries(NULL, NULL, 1, &av); + (void)rpmGetMacroEntries(NULL, NULL, 1, &av); /*...@=globs@*/ - argvPrint("macros used", av, NULL); - av = argvFree(av); - } + argvPrint("macros used", av, NULL); + av = argvFree(av); + } - (void) rpmtsUnlink(ts, "tsCreate"); - /*...@-refcounttrans -usereleased @*/ - ts = _free(ts); - /*...@=refcounttrans =usereleased @*/ + ts = (rpmts) rpmioPutPool((rpmioItem)ts); + } else + yarnTwist(ts->use, BY, -1); return NULL; } @@ -1374,10 +1382,9 @@ rpmts rpmtsCreate(void) { - rpmts ts; + rpmts ts = rpmtsGetPool(_rpmtsPool); int xx; - ts = xcalloc(1, sizeof(*ts)); memset(&ts->ops, 0, sizeof(ts->ops)); (void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_TOTAL), -1); ts->type = RPMTRANS_TYPE_NORMAL; @@ -1448,7 +1455,5 @@ /* Set autorollback goal to the end of time. */ ts->arbgoal = 0xffffffff; - ts->nrefs = 0; - return rpmtsLink(ts, "tsCreate"); } @@ . patch -p0 <<'@@ .' Index: rpm/lib/rpmts.h ============================================================================ $ cvs diff -u -r2.109 -r2.110 rpmts.h --- rpm/lib/rpmts.h 8 Dec 2008 04:04:24 -0000 2.109 +++ rpm/lib/rpmts.h 19 Mar 2009 14:57:21 -0000 2.110 @@ -201,6 +201,10 @@ * The set of packages to be installed/removed atomically. */ struct rpmts_s { + yarnLock use; /*!< use count -- return to pool when zero */ +/*...@shared@*/ /*...@null@*/ + void *pool; /*!< pool (or NULL if malloc'd) */ + rpmdepFlags depFlags; /*!< Bit(s) to control rpmtsCheck(). */ rpmtransFlags transFlags; /*!< Bit(s) to control rpmtsRun(). */ tsmStage goal; /*!< Transaction goal (i.e. mode) */ @@ -315,8 +319,6 @@ rpmuint32_t arbgoal; /*!< Autorollback goal */ -/*...@refs@*/ - int nrefs; /*!< Reference count. */ }; #endif /* _RPMTS_INTERNAL */ @@ -402,15 +404,8 @@ rpmts rpmtsUnlink (/*...@killref@*/ /*...@only@*/ rpmts ts, const char * msg) /*...@modifies ts @*/; - -/** @todo Remove debugging entry from the ABI. */ -/*...@-exportlocal@*/ -/*...@null@*/ -rpmts XrpmtsUnlink (/*...@killref@*/ /*...@only@*/ rpmts ts, - const char * msg, const char * fn, unsigned ln) - /*...@modifies ts @*/; -/*...@=exportlocal@*/ -#define rpmtsUnlink(_ts, _msg) XrpmtsUnlink(_ts, _msg, __FILE__, __LINE__) +#define rpmtsUnlink(_ts, _msg) \ + ((rpmts) rpmioUnlinkPoolItem((rpmioItem)(_ts), _msg, __FILE__, __LINE__)) /** \ingroup rpmts * Reference a transaction set instance. @@ -418,15 +413,11 @@ * @param msg * @return new transaction set reference */ -/*...@unused@*/ +/*...@unused@*/ /*...@newref@*/ rpmts rpmtsLink (rpmts ts, const char * msg) /*...@modifies ts @*/; - -/** @todo Remove debugging entry from the ABI. */ -rpmts XrpmtsLink (rpmts ts, - const char * msg, const char * fn, unsigned ln) - /*...@modifies ts @*/; -#define rpmtsLink(_ts, _msg) XrpmtsLink(_ts, _msg, __FILE__, __LINE__) +#define rpmtsLink(_ts, _msg) \ + ((rpmts) rpmioLinkPoolItem((rpmioItem)(_ts), _msg, __FILE__, __LINE__)) /** \ingroup rpmts * Close the database used by the transaction. @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org