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: 17-Mar-2009 14:46:12 Branch: rpm-5_1 Handle: 2009031713461200 Modified files: (Branch: rpm-5_1) rpm CHANGES rpm/lib rpmds.c rpmds.h Log: - yarn: convert rpmds refcounts to usage mutexes. Summary: Revision Changes Path 1.2288.2.200+1 -0 rpm/CHANGES 2.94.2.8 +21 -8 rpm/lib/rpmds.c 2.66.2.4 +1 -2 rpm/lib/rpmds.h ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/CHANGES ============================================================================ $ cvs diff -u -r1.2288.2.199 -r1.2288.2.200 CHANGES --- rpm/CHANGES 16 Mar 2009 20:29:55 -0000 1.2288.2.199 +++ rpm/CHANGES 17 Mar 2009 13:46:12 -0000 1.2288.2.200 @@ -1,4 +1,5 @@ 5.1.7 -> 5.1.8: + - jbj: yarn: convert rpmds refcounts to usage mutexes. - jbj: yarn: convert Header refcounts to usage mutexes. - jbj: yarn: convert urlInfo refcounts to usage mutexes. - jbj: yarn: convert FD_t refcounts to usage mutexes. @@ . patch -p0 <<'@@ .' Index: rpm/lib/rpmds.c ============================================================================ $ cvs diff -u -r2.94.2.7 -r2.94.2.8 rpmds.c --- rpm/lib/rpmds.c 16 Mar 2009 10:32:04 -0000 2.94.2.7 +++ rpm/lib/rpmds.c 17 Mar 2009 13:46:12 -0000 2.94.2.8 @@ -119,23 +119,24 @@ rpmds XrpmdsUnlink(rpmds ds, const char * msg, const char * fn, unsigned ln) { if (ds == NULL) return NULL; + yarnPossess(ds->use); /*...@-modfilesys@*/ if (_rpmds_debug && msg != NULL) -fprintf(stderr, "--> ds %p -- %d %s at %s:%u\n", ds, ds->nrefs, msg, fn, ln); +fprintf(stderr, "--> ds %p -- %ld %s at %s:%u\n", ds, yarnPeekLock(ds->use), msg, fn, ln); /*...@=modfilesys@*/ - ds->nrefs--; + yarnTwist(ds->use, BY, -1); return NULL; } rpmds XrpmdsLink(rpmds ds, const char * msg, const char * fn, unsigned ln) { if (ds == NULL) return NULL; - ds->nrefs++; - + yarnPossess(ds->use); /*...@-modfilesys@*/ if (_rpmds_debug && msg != NULL) -fprintf(stderr, "--> ds %p ++ %d %s at %s:%u\n", ds, ds->nrefs, msg, fn, ln); +fprintf(stderr, "--> ds %p ++ %ld %s at %s:%u\n", ds, yarnPeekLock(ds->use)+1, msg, fn, ln); /*...@=modfilesys@*/ + yarnTwist(ds->use, BY, 1); /*...@-refcounttrans@*/ return ds; /*...@=refcounttrans@*/ } @@ -179,8 +180,13 @@ if (ds == NULL) return NULL; - if (ds->nrefs > 1) - return rpmdsUnlink(ds, ds->Type); + yarnPossess(ds->use); +/*...@-modfilesys@*/ +if (_rpmds_debug) +fprintf(stderr, "--> ds %p -- %ld %s at %s:%u\n", ds, yarnPeekLock(ds->use), ds->Type, __FILE__, __LINE__); +/*...@=modfilesys@*/ + if (yarnPeekLock(ds->use) <= 1) { + yarnLock use = ds->use; /*...@-modfilesys@*/ if (_rpmds_debug < 0) @@ -204,11 +210,14 @@ ds->exclude = mireFreeAll(ds->exclude, ds->nexclude); ds->include = mireFreeAll(ds->include, ds->ninclude); - (void) rpmdsUnlink(ds, ds->Type); /*...@-refcounttrans -userelea...@*/ memset(ds, 0, sizeof(*ds)); /* XXX trash and burn */ ds = _free(ds); /*...@=refcounttrans =userelea...@*/ + yarnTwist(use, BY, -1); + use = yarnFreeLock(use); + } else + yarnTwist(ds->use, BY, -1); return NULL; } @@ -314,6 +323,7 @@ Count = he->c; if (xx && N != NULL && Count > 0) { ds = xcalloc(1, sizeof(*ds)); + ds->use = yarnNewLock(0); ds->Type = Type; ds->h = NULL; ds->i = -1; @@ -564,6 +574,7 @@ R = _free(R); ds = xcalloc(1, sizeof(*ds)); + ds->use = yarnNewLock(0); ds->Type = Type; ds->tagN = tagN; ds->Count = 1; @@ -599,6 +610,7 @@ Type = rpmdsTagName(tagN); ds = xcalloc(1, sizeof(*ds)); + ds->use = yarnNewLock(0); ds->Type = Type; ds->tagN = tagN; ds->A = NULL; @@ -945,6 +957,7 @@ size_t nb; ds->h = (ods->h != NULL ? headerLink(ods->h) : NULL); + ds->use = yarnNewLock(0); /*...@-assignexpose@*/ ds->Type = ods->Type; /*...@=assignexpose@*/ @@ . patch -p0 <<'@@ .' Index: rpm/lib/rpmds.h ============================================================================ $ cvs diff -u -r2.66.2.3 -r2.66.2.4 rpmds.h --- rpm/lib/rpmds.h 10 Dec 2008 19:56:51 -0000 2.66.2.3 +++ rpm/lib/rpmds.h 17 Mar 2009 13:46:12 -0000 2.66.2.4 @@ -37,6 +37,7 @@ * A dependency set. */ struct rpmds_s { + yarnLock use; /*!< use count -- return to pool when zero */ /*...@observer@*/ const char * Type; /*!< Tag name. */ /*...@only@*/ /*...@null@*/ @@ -74,8 +75,6 @@ unsigned l; /*!< Low element (bsearch). */ unsigned u; /*!< High element (bsearch). */ int nopromote; /*!< Don't promote Epoch: in rpmdsCompare()? */ -/*...@refs@*/ - int nrefs; /*!< Reference count. */ }; #endif /* _RPMDS_INTERNAL */ @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org