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 18:33:43
  Branch: HEAD                             Handle: 2009031917334300

  Modified files:
    rpm                     CHANGES
    rpm/rpmio               rpmio.c rpmxar.c rpmxar.h

  Log:
    - yarn: convert rpmxar refcount to usage mutex.

  Summary:
    Revision    Changes     Path
    1.2847      +1  -0      rpm/CHANGES
    1.168       +3  -1      rpm/rpmio/rpmio.c
    2.18        +23 -34     rpm/rpmio/rpmxar.c
    2.10        +9  -18     rpm/rpmio/rpmxar.h
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.2846 -r1.2847 CHANGES
  --- rpm/CHANGES       19 Mar 2009 16:29:24 -0000      1.2846
  +++ rpm/CHANGES       19 Mar 2009 17:33:43 -0000      1.2847
  @@ -1,5 +1,6 @@
   
   5.2a3 -> 5.2a4:
  +    - 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).
       - jbj: rpmps: fix: avoid reusing items from pool for now.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmio.c
  ============================================================================
  $ cvs diff -u -r1.167 -r1.168 rpmio.c
  --- rpm/rpmio/rpmio.c 19 Mar 2009 16:29:24 -0000      1.167
  +++ rpm/rpmio/rpmio.c 19 Mar 2009 17:33:43 -0000      1.168
  @@ -3154,6 +3154,7 @@
   void rpmioClean(void)
   {
       extern rpmioPool _digPool;
  +    extern rpmioPool _xarPool;
       extern rpmioPool _urlPool;
   
   #if defined(WITH_LUA)
  @@ -3170,8 +3171,9 @@
   #endif
       urlFreeCache();
   
  -    _urlPool = rpmioFreePool(_urlPool);
       _digPool = rpmioFreePool(_digPool);
  +    _xarPool = rpmioFreePool(_xarPool);
  +    _urlPool = rpmioFreePool(_urlPool);
       _fdPool = rpmioFreePool(_fdPool);
   
       rpmlogClose();
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmxar.c
  ============================================================================
  $ cvs diff -u -r2.17 -r2.18 rpmxar.c
  --- rpm/rpmio/rpmxar.c        10 Mar 2008 04:46:20 -0000      2.17
  +++ rpm/rpmio/rpmxar.c        19 Mar 2009 17:33:43 -0000      2.18
  @@ -58,8 +58,7 @@
   
   #define      _RPMXAR_INTERNAL
   #include <rpmxar.h>
  -
  -#include <rpmio_internal.h>
  +#include <rpmio_internal.h>  /* for fdGetXAR */
   
   #include "debug.h"
   
  @@ -68,38 +67,31 @@
   /*...@unchecked@*/
   int _xar_debug = 0;
   
  -rpmxar XrpmxarUnlink(rpmxar xar, const char * msg, const char * fn, unsigned 
ln)
  -{
  -    if (xar == NULL) return NULL;
  -/*...@-modfilesys@*/
  -if (_xar_debug && msg != NULL)
  -fprintf(stderr, "--> xar %p -- %d %s at %s:%u\n", xar, xar->nrefs, msg, fn, 
ln);
  -/*...@=modfilesys@*/
  -    xar->nrefs--;
  -    return NULL;
  -}
  +/*...@unchecked@*/ /*...@null@*/
  +rpmioPool _xarPool;
   
  -rpmxar XrpmxarLink(rpmxar xar, const char * msg, const char * fn, unsigned 
ln)
  +static rpmxar rpmxarGetPool(/*...@null@*/ rpmioPool pool)
  +     /*...@modifies pool @*/
   {
  -    if (xar == NULL) return NULL;
  -    xar->nrefs++;
  +    rpmxar xar;
   
  -/*...@-modfilesys@*/
  -if (_xar_debug && msg != NULL)
  -fprintf(stderr, "--> xar %p ++ %d %s at %s:%u\n", xar, xar->nrefs, msg, fn, 
ln);
  -/*...@=modfilesys@*/
  -
  -    /*...@-refcounttrans@*/ return xar; /*...@=refcounttrans@*/
  +    if (_xarPool == NULL) {
  +     _xarPool = rpmioNewPool("xar", sizeof(*xar), -1, _xar_debug);
  +     pool = _xarPool;
  +    }
  +    return (rpmxar) rpmioGetPool(pool, sizeof(*xar));
   }
  -
   rpmxar rpmxarFree(rpmxar xar)
   {
  -    if (xar) {
  -
  +    if (xar == NULL)
  +     return NULL;
  +    yarnPossess(xar->use);
  +/*...@-modfilesys@*/
  +if (_xar_debug)
  +fprintf(stderr, "--> xar %p -- %ld %s at %s:%u\n", xar, 
yarnPeekLock(xar->use), "rpmxarFree", __FILE__, __LINE__);
  +/*...@=modfilesys@*/
  +    if (yarnPeekLock(xar->use) <= 1L) {
   /*...@-onlytrans@*/
  -     if (xar->nrefs > 1)
  -         return rpmxarUnlink(xar, "rpmxarFree");
  -
        if (xar->i) {
            xar_iter_free(xar->i);
            xar->i = NULL;
  @@ -113,19 +105,16 @@
        xar->member = _free(xar->member);
        xar->b = _free(xar->b);
   
  -     (void) rpmxarUnlink(xar, "rpmxarFree");
   /*...@=onlytrans@*/
  -     /*...@-refcounttrans -userelea...@*/
  -     memset(xar, 0, sizeof(*xar));         /* XXX trash and burn */
  -     xar = _free(xar);
  -     /*...@=refcounttrans =userelea...@*/
  -    }
  +     xar = (rpmxar) rpmioPutPool((rpmioItem)xar);
  +    } else
  +     yarnTwist(xar->use, BY, -1);
       return NULL;
   }
   
   rpmxar rpmxarNew(const char * fn, const char * fmode)
   {
  -    rpmxar xar = xcalloc(1, sizeof(*xar));
  +    rpmxar xar = rpmxarGetPool(_xarPool);
       int flags = ((fmode && *fmode == 'w') ? WRITE : READ);
   
   assert(fn != NULL);
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmxar.h
  ============================================================================
  $ cvs diff -u -r2.9 -r2.10 rpmxar.h
  --- rpm/rpmio/rpmxar.h        23 Nov 2007 23:52:36 -0000      2.9
  +++ rpm/rpmio/rpmxar.h        19 Mar 2009 17:33:43 -0000      2.10
  @@ -12,7 +12,12 @@
   typedef /*...@abstract@*/ /*...@refcounted@*/ struct rpmxar_s * rpmxar;
   
   #ifdef       _RPMXAR_INTERNAL
  +#include "yarn.h"
   struct rpmxar_s {
  +    yarnLock use;            /*!< use count -- return to pool when zero */
  +/*...@shared@*/ /*...@null@*/
  +    void *pool;                      /*!< pool (or NULL if malloc'd) */
  +
   /*...@relnull@*/
       const void * x;          /*!< xar_t */
   /*...@relnull@*/
  @@ -26,8 +31,6 @@
       size_t bsize;            /*!< No. bytes of data. */
       size_t bx;                       /*!< Data byte index. */
       int first;
  -/*...@refs@*/
  -    int nrefs;                       /*!< Reference count. */
   };
   #endif
   
  @@ -45,15 +48,8 @@
   rpmxar rpmxarUnlink (/*...@killref@*/ /*...@only@*/ /*...@null@*/ rpmxar xar,
                /*...@null@*/ const char * msg)
        /*...@modifies xar @*/;
  -
  -/** @todo Remove debugging entry from the ABI. */
  -/*...@-exportlocal@*/
  -/*...@null@*/
  -rpmxar XrpmxarUnlink (/*...@killref@*/ /*...@only@*/ /*...@null@*/ rpmxar 
xar,
  -             /*...@null@*/ const char * msg, const char * fn, unsigned ln)
  -     /*...@modifies xar @*/;
  -/*...@=exportlocal@*/
  -#define      rpmxarUnlink(_xar, _msg) XrpmxarUnlink(_xar, _msg, __FILE__, 
__LINE__)
  +#define      rpmxarUnlink(_xar, _msg)        \
  +    ((rpmxar)rpmioUnlinkPoolItem((rpmioItem)(_xar), _msg, __FILE__, 
__LINE__))
   
   /**
    * Reference a xar archive instance.
  @@ -64,13 +60,8 @@
   /*...@unused@*/ /*...@newref@*/ /*...@null@*/
   rpmxar rpmxarLink (/*...@null@*/ rpmxar xar, /*...@null@*/ const char * msg)
        /*...@modifies xar @*/;
  -
  -/** @todo Remove debugging entry from the ABI. */
  -/*...@newref@*/ /*...@null@*/
  -rpmxar XrpmxarLink (/*...@null@*/ rpmxar xar, /*...@null@*/ const char * msg,
  -             const char * fn, unsigned ln)
  -        /*...@modifies xar @*/;
  -#define      rpmxarLink(_xar, _msg)  XrpmxarLink(_xar, _msg, __FILE__, 
__LINE__)
  +#define      rpmxarLink(_xar, _msg)  \
  +    ((rpmxar)rpmioLinkPoolItem((rpmioItem)(_xar), _msg, __FILE__, __LINE__))
   
   /*...@null@*/
   rpmxar rpmxarFree(/*...@killref@*/ /*...@only@*/ rpmxar xar)
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                rpm-cvs@rpm5.org

Reply via email to