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:   18-Mar-2009 23:31:40
  Branch: HEAD                             Handle: 2009031822313900

  Modified files:
    rpm                     CHANGES
    rpm/lib                 librpm.vers poptALL.c rpmps.c rpmps.h

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

  Summary:
    Revision    Changes     Path
    1.2840      +1  -0      rpm/CHANGES
    1.58        +0  -2      rpm/lib/librpm.vers
    2.109       +4  -0      rpm/lib/poptALL.c
    2.29        +37 -15     rpm/lib/rpmps.c
    2.24        +10 -19     rpm/lib/rpmps.h
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.2839 -r1.2840 CHANGES
  --- rpm/CHANGES       18 Mar 2009 22:11:21 -0000      1.2839
  +++ rpm/CHANGES       18 Mar 2009 22:31:39 -0000      1.2840
  @@ -1,5 +1,6 @@
   
   5.2a3 -> 5.2a4:
  +    - jbj: yarn: convert rpmps refcount to usage mutex.
       - jbj: rpmds: fix: avoid pooling rpmdsThis/rpmdsSingle for now ...
       - jbj: headerReload: fix: don't free the header blob.
       - jbj: yarn: convert rpmte to a usage mutex (no refcounts).
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/librpm.vers
  ============================================================================
  $ cvs diff -u -r1.57 -r1.58 librpm.vers
  --- rpm/lib/librpm.vers       18 Mar 2009 19:59:50 -0000      1.57
  +++ rpm/lib/librpm.vers       18 Mar 2009 22:31:39 -0000      1.58
  @@ -408,10 +408,8 @@
       tarHeaderRead;
       tarHeaderWrite;
       tarTrailerWrite;
  -    XrpmpsLink;
       XrpmpsmLink;
       XrpmpsmUnlink;
  -    XrpmpsUnlink;
       XrpmsxLink;
       XrpmsxUnlink;
       XrpmtsiFree;
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/poptALL.c
  ============================================================================
  $ cvs diff -u -r2.108 -r2.109 poptALL.c
  --- rpm/lib/poptALL.c 18 Mar 2009 21:02:43 -0000      2.108
  +++ rpm/lib/poptALL.c 18 Mar 2009 22:31:39 -0000      2.109
  @@ -109,6 +109,8 @@
   
   /*...@unchecked@*/
   extern int _rpmps_debug;
  +/*...@unchecked@*/
  +extern rpmioPool _rpmpsPool;
   
   /*...@unchecked@*/
   extern int _rpmsq_debug;
  @@ -457,7 +459,9 @@
       extern rpmioPool _headerPool;
   
       _rpmgiPool = rpmioFreePool(_rpmgiPool);
  +
       _rpmtePool = rpmioFreePool(_rpmtePool);
  +    _rpmpsPool = rpmioFreePool(_rpmpsPool);
   
       _rpmdsPool = rpmioFreePool(_rpmdsPool);
       _rpmfiPool = rpmioFreePool(_rpmfiPool);
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/rpmps.c
  ============================================================================
  $ cvs diff -u -r2.28 -r2.29 rpmps.c
  --- rpm/lib/rpmps.c   7 Oct 2008 20:05:56 -0000       2.28
  +++ rpm/lib/rpmps.c   18 Mar 2009 22:31:39 -0000      2.29
  @@ -19,6 +19,23 @@
   /*...@unchecked@*/
   int _rpmps_debug = 0;
   
  +
  +/*...@unchecked@*/ /*...@null@*/
  +rpmioPool _rpmpsPool;
  +
  +static rpmps rpmpsGetPool(/*...@null@*/ rpmioPool pool)
  +     /*...@modifies pool @*/
  +{
  +    rpmps ps;
  +
  +    if (_rpmpsPool == NULL) {
  +     _rpmpsPool = rpmioNewPool("ps", sizeof(*ps), -1, _rpmps_debug);
  +     pool = _rpmpsPool;
  +    }
  +    return (rpmps) rpmioGetPool(pool, sizeof(*ps));
  +}
  +
  +#ifdef       DYING
   rpmps XrpmpsUnlink(rpmps ps, const char * msg,
                const char * fn, unsigned ln)
   {
  @@ -44,6 +61,7 @@
       return ps;
   /*...@=refcounttrans@*/
   }
  +#endif
   
   int rpmpsNumProblems(rpmps ps)
   {
  @@ -98,28 +116,32 @@
   
   rpmps rpmpsCreate(void)
   {
  -    rpmps ps = xcalloc(1, sizeof(*ps));
  +    rpmps ps = rpmpsGetPool(_rpmpsPool);
       return rpmpsLink(ps, "create");
   }
   
   rpmps rpmpsFree(rpmps ps)
   {
       if (ps == NULL) return NULL;
  -    ps = rpmpsUnlink(ps, "dereference");
  -    if (ps->nrefs > 0)
  -     return NULL;
  -     
  -    if (ps->probs) {
  -     int i;
  -     for (i = 0; i < ps->numProblems; i++) {
  -         rpmProblem p = ps->probs + i;
  -         p->pkgNEVR = _free(p->pkgNEVR);
  -         p->altNEVR = _free(p->altNEVR);
  -         p->str1 = _free(p->str1);
  +    yarnPossess(ps->use);
  +/*...@-modfilesys@*/
  +if (_rpmps_debug)
  +fprintf(stderr, "--> ps %p -- %d %s at %s:%u\n", ps, yarnPeekLock(ps->use), 
"rpmpsFree", __FILE__, __LINE__);
  +/*...@=modfilesys@*/
  +    if (yarnPeekLock(ps->use) <= 1L) {
  +     if (ps->probs) {
  +         int i;
  +         for (i = 0; i < ps->numProblems; i++) {
  +             rpmProblem p = ps->probs + i;
  +             p->pkgNEVR = _free(p->pkgNEVR);
  +             p->altNEVR = _free(p->altNEVR);
  +             p->str1 = _free(p->str1);
  +         }
  +         ps->probs = _free(ps->probs);
        }
  -     ps->probs = _free(ps->probs);
  -    }
  -    ps = _free(ps);
  +     ps = (rpmps) rpmioPutPool((rpmioItem)ps);
  +    } else
  +     yarnTwist(ps->use, BY, -1);
       return NULL;
   }
   
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/rpmps.h
  ============================================================================
  $ cvs diff -u -r2.23 -r2.24 rpmps.h
  --- rpm/lib/rpmps.h   4 Oct 2008 18:12:35 -0000       2.23
  +++ rpm/lib/rpmps.h   18 Mar 2009 22:31:39 -0000      2.24
  @@ -82,11 +82,13 @@
   /**
    */
   struct rpmps_s {
  +    yarnLock use;            /*!< use count -- return to pool when zero */
  +/*...@shared@*/ /*...@null@*/
  +    void *pool;                      /*!< pool (or NULL if malloc'd) */
  +
       int numProblems;         /*!< Current probs array size. */
       int numProblemsAlloced;  /*!< Allocated probs array size. */
       rpmProblem probs;                /*!< Array of specific problems. */
  -/*...@refs@*/
  -    int nrefs;                       /*!< Reference count. */
   };
   
   /**
  @@ -120,19 +122,12 @@
    * @param msg
    * @return           problem set
    */
  -/*...@unused@*/
  +/*...@unused@*/ /*...@null@*/
   rpmps rpmpsUnlink (/*...@killref@*/ /*...@returned@*/ rpmps ps,
                const char * msg)
        /*...@modifies ps @*/;
  -
  -/** @todo Remove debugging entry from the ABI. */
  -/*...@-exportlocal@*/
  -/*...@null@*/
  -rpmps XrpmpsUnlink (/*...@killref@*/ /*...@returned@*/ rpmps ps,
  -             const char * msg, const char * fn, unsigned ln)
  -     /*...@modifies ps @*/;
  -#define      rpmpsUnlink(_ps, _msg)  XrpmpsUnlink(_ps, _msg, __FILE__, 
__LINE__)
  -/*...@=exportlocal@*/
  +#define      rpmpsUnlink(_ps, _msg)  \
  +     ((rpmps)rpmioUnlinkPoolItem((rpmioItem)(_ps), _msg, __FILE__, __LINE__))
   
   /**
    * Reference a problem set instance.
  @@ -140,15 +135,11 @@
    * @param msg
    * @return           new transaction set reference
    */
  -/*...@unused@*/
  +/*...@unused@*/ /*...@newref@*/
   rpmps rpmpsLink (rpmps ps, const char * msg)
        /*...@modifies ps @*/;
  -
  -/** @todo Remove debugging entry from the ABI. */
  -rpmps XrpmpsLink (rpmps ps,
  -             const char * msg, const char * fn, unsigned ln)
  -        /*...@modifies ps @*/;
  -#define      rpmpsLink(_ps, _msg)    XrpmpsLink(_ps, _msg, __FILE__, 
__LINE__)
  +#define      rpmpsLink(_ps, _msg)    \
  +     ((rpmps)rpmioLinkPoolItem((rpmioItem)(_ps), _msg, __FILE__, __LINE__))
   
   /**
    * Return number of problems in set.
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                rpm-cvs@rpm5.org

Reply via email to