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: 16-Mar-2009 21:29:56 Branch: rpm-5_1 Handle: 2009031620295501 Modified files: (Branch: rpm-5_1) rpm CHANGES rpm/rpmdb header.c header_internal.h Log: - yarn: convert Header refcounts to usage mutexes. Summary: Revision Changes Path 1.2288.2.199+1 -0 rpm/CHANGES 1.153.2.5 +26 -14 rpm/rpmdb/header.c 1.40.2.4 +8 -3 rpm/rpmdb/header_internal.h ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/CHANGES ============================================================================ $ cvs diff -u -r1.2288.2.198 -r1.2288.2.199 CHANGES --- rpm/CHANGES 16 Mar 2009 18:22:25 -0000 1.2288.2.198 +++ rpm/CHANGES 16 Mar 2009 20:29:55 -0000 1.2288.2.199 @@ -1,4 +1,5 @@ 5.1.7 -> 5.1.8: + - 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. - jbj: zlog: backport from HEAD. @@ . patch -p0 <<'@@ .' Index: rpm/rpmdb/header.c ============================================================================ $ cvs diff -u -r1.153.2.4 -r1.153.2.5 header.c --- rpm/rpmdb/header.c 11 Jan 2009 17:23:21 -0000 1.153.2.4 +++ rpm/rpmdb/header.c 16 Mar 2009 20:29:56 -0000 1.153.2.5 @@ -107,11 +107,12 @@ if (h == NULL) return NULL; /*...@=nullret@*/ - h->nrefs++; + yarnPossess(h->use); /*...@-modfilesys@*/ if (_hdr_debug) -fprintf(stderr, "--> h %p ++ %d at %s:%u\n", h, h->nrefs, __FILE__, __LINE__); +fprintf(stderr, "--> h %p ++ %ld at %s:%u\n", h, yarnPeekLock(h->use)+1, __FILE__, __LINE__); /*...@=modfilesys@*/ + yarnTwist(h->use, BY, 1); /*...@-refcounttrans @*/ return h; @@ -121,27 +122,35 @@ Header headerUnlink(Header h) { if (h == NULL) return NULL; + yarnPossess(h->use); /*...@-modfilesys@*/ if (_hdr_debug) -fprintf(stderr, "--> h %p -- %d at %s:%u\n", h, h->nrefs, __FILE__, __LINE__); +fprintf(stderr, "--> h %p -- %ld at %s:%u\n", h, yarnPeekLock(h->use), __FILE__, __LINE__); /*...@=modfilesys@*/ - h->nrefs--; + yarnTwist(h->use, BY, -1); return NULL; } Header headerFree(Header h) { - (void) headerUnlink(h); - /*...@-usereleased@*/ - if (h == NULL || h->nrefs > 0) - return NULL; /* XXX return previous header? */ + if (h == NULL) + return NULL; - if (h->index) { + yarnPossess(h->use); +/*...@-modfilesys@*/ +if (_hdr_debug) +fprintf(stderr, "--> h %p -- %ld at %s:%u\n", h, yarnPeekLock(h->use), __FILE__, __LINE__); +/*...@=modfilesys@*/ + if (yarnPeekLock(h->use) <= 1L) { + yarnLock use = h->use; +/*...@-usereleased@*/ + if (h->index != NULL) { indexEntry entry = h->index; size_t i; for (i = 0; i < h->indexUsed; i++, entry++) { - if ((h->flags & HEADERFLAG_ALLOCATED) && ENTRY_IS_REGION(entry)) { + if ((h->flags & HEADERFLAG_ALLOCATED) && ENTRY_IS_REGION(entry)) + { if (entry->length > 0) { uint32_t * ei = entry->data; if ((ei - 2) == h->blob) @@ -167,10 +176,13 @@ (void) rpmswAdd(_hdr_getops, headerGetStats(h, 19)); } /*...@=nullstate@*/ - /*...@-refcounttrans@*/ h = _free(h); /*...@=refcounttrans@*/ - return h; + yarnTwist(use, BY, -1); + use = yarnFreeLock(use); /*...@=usereleased@*/ + } else + yarnTwist(h->use, BY, -1); + return NULL; } Header headerNew(void) @@ -192,7 +204,7 @@ ? xcalloc(h->indexAlloced, sizeof(*h->index)) : NULL); - h->nrefs = 0; + h->use = yarnNewLock(0); /*...@-globstate -observertrans @*/ return headerLink(h); /*...@=globstate =observertrans @*/ @@ -1049,7 +1061,7 @@ h->indexUsed = il; h->index = xcalloc(h->indexAlloced, sizeof(*h->index)); h->flags |= HEADERFLAG_SORTED; - h->nrefs = 0; + h->use = yarnNewLock(0);; h->startoff = 0; h->endoff = (uint32_t) pvlen; h = headerLink(h); @@ . patch -p0 <<'@@ .' Index: rpm/rpmdb/header_internal.h ============================================================================ $ cvs diff -u -r1.40.2.3 -r1.40.2.4 header_internal.h --- rpm/rpmdb/header_internal.h 11 Jan 2009 17:23:21 -0000 1.40.2.3 +++ rpm/rpmdb/header_internal.h 16 Mar 2009 20:29:56 -0000 1.40.2.4 @@ -6,6 +6,7 @@ */ #include <rpmtag.h> +#include <yarn.h> #if !defined(__LCLINT__) #include <netinet/in.h> @@ -82,6 +83,8 @@ * The Header data structure. */ struct headerToken_s { +/*...@relnull@*/ + yarnLock use; unsigned char magic[8]; /*!< Header magic. */ /*...@only@*/ /*...@null@*/ void * blob; /*!< Header region blob. */ @@ -109,8 +112,6 @@ #define HEADERFLAG_LEGACY (1 << 2) /*!< Header came from legacy source? */ #define HEADERFLAG_DEBUG (1 << 3) /*!< Debug this header? */ #define HEADERFLAG_SIGNATURE (1 << 4) /*!< Signature header? */ -/*...@refs@*/ - int nrefs; /*!< Reference count. */ }; #ifdef __cplusplus @@ -136,7 +137,11 @@ */ /*...@-type@*/ /* FIX: cast? */ /*...@unused@*/ static inline int headerUsageCount(Header h) /*...@*/ { - return h->nrefs; + int nrefs = 0; + yarnPossess(h->use); + nrefs = (int)yarnPeekLock(h->use); + yarnRelease(h->use); + return nrefs; } /*...@=type@*/ @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org