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:   30-Mar-2009 00:42:25
  Branch: HEAD                             Handle: 2009032922422301

  Modified files:
    rpm                     CHANGES
    rpm/rpmdb               rpmdb.c
    rpm/rpmio               librpmio.vers mire.c mire.h rpmio.c

  Log:
    -  yarn: convert mire to usage mutex with refcounts
        (unifying array <-> element mutexes by copying use/pool
        pointers throughout the array).

  Summary:
    Revision    Changes     Path
    1.2887      +3  -0      rpm/CHANGES
    1.289       +14 -8      rpm/rpmdb/rpmdb.c
    2.102       +2  -0      rpm/rpmio/librpmio.vers
    1.49        +49 -36     rpm/rpmio/mire.c
    1.29        +17 -1      rpm/rpmio/mire.h
    1.177       +2  -0      rpm/rpmio/rpmio.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.2886 -r1.2887 CHANGES
  --- rpm/CHANGES       29 Mar 2009 21:44:05 -0000      1.2886
  +++ rpm/CHANGES       29 Mar 2009 22:42:23 -0000      1.2887
  @@ -1,5 +1,8 @@
   
   5.2a3 -> 5.2a4:
  +    - jbj: yarn: convert mire to usage mutex with refcounts
  +     (unifying array <-> element mutexes by copying use/pool
  +     pointers throughout the array).
       - jbj: rpmku: rework rpmiob handling to avoid extra malloc's.
       - jbj: rpmiob: fix: add a newref in rpmiobNew.
       - jbj: yarn: convert rpmiob to usage mutex with refcounts.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/rpmdb.c
  ============================================================================
  $ cvs diff -u -r1.288 -r1.289 rpmdb.c
  --- rpm/rpmdb/rpmdb.c 29 Mar 2009 20:59:13 -0000      1.288
  +++ rpm/rpmdb/rpmdb.c 29 Mar 2009 22:42:24 -0000      1.289
  @@ -1932,7 +1932,6 @@
       rpmdbMatchIterator * prev, next;
       dbiIndex dbi;
       int xx;
  -    int i;
   
       if (mi == NULL)
        return NULL;
  @@ -1955,10 +1954,7 @@
        xx = dbiCclose(dbi, mi->mi_dbc, 0);
       mi->mi_dbc = NULL;
   
  -    if (mi->mi_re != NULL)
  -    for (i = 0; i < mi->mi_nre; i++)
  -     xx = mireClean(mi->mi_re + i);
  -    mi->mi_re = _free(mi->mi_re);
  +    mi->mi_re = mireFreeAll(mi->mi_re, mi->mi_nre);
   
       mi->mi_set = dbiFreeIndexSet(mi->mi_set);
       /* XXX rpmdbUnlink will not do.
  @@ -2144,8 +2140,19 @@
       if (rc)
        goto exit;
   
  -    mi->mi_re = xrealloc(mi->mi_re, (mi->mi_nre + 1) * sizeof(*mi->mi_re));
  -    mire = mi->mi_re + mi->mi_nre;
  +    if (mi->mi_re == NULL) {
  +     mi->mi_re = mireGetPool(_mirePool);
  +     mire = mi->mi_re;
  +    } else {
  +     void *use =  mi->mi_re->_item.use;
  +     void *pool = mi->mi_re->_item.pool;
  +     mi->mi_re = xrealloc(mi->mi_re, (mi->mi_nre + 1) * sizeof(*mi->mi_re));
  +     mire = mi->mi_re + mi->mi_nre;
  +     memset(mire, 0, sizeof(*mire));
  +     /* XXX ensure no segfault, copy the use/pool from 1st item. */
  +     mire->_item.use = use;
  +     mire->_item.pool = pool;
  +    }
       mi->mi_nre++;
       
       mire->mode = nmire->mode;
  @@ -2159,7 +2166,6 @@
       /* XXX todo: permit PCRE patterns to be used. */
       mire->offsets = NULL;
       mire->noffsets = 0;
  -    mire->nrefs = 0;
   
       if (mi->mi_nre > 1)
        qsort(mi->mi_re, mi->mi_nre, sizeof(*mi->mi_re), mireCmp);
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/librpmio.vers
  ============================================================================
  $ cvs diff -u -r2.101 -r2.102 librpmio.vers
  --- rpm/rpmio/librpmio.vers   29 Mar 2009 18:42:22 -0000      2.101
  +++ rpm/rpmio/librpmio.vers   29 Mar 2009 22:42:24 -0000      2.102
  @@ -165,12 +165,14 @@
       lzdio;
       max_macro_depth;
       _mire_debug;
  +    _mirePool;
       mireAppend;
       mireApply;
       mireClean;
       _mireEL;
       mireFree;
       mireFreeAll;
  +    mireGetPool;
       _mireGLOBoptions;
       mireLoadPatterns;
       mireNew;
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/mire.c
  ============================================================================
  $ cvs diff -u -r1.48 -r1.49 mire.c
  --- rpm/rpmio/mire.c  2 Mar 2009 00:45:55 -0000       1.48
  +++ rpm/rpmio/mire.c  29 Mar 2009 22:42:24 -0000      1.49
  @@ -4,6 +4,7 @@
   #include "system.h"
   
   #include <rpmiotypes.h>
  +#include <rpmio.h>
   #include <rpmlog.h>
   
   #define      _MIRE_INTERNAL
  @@ -68,44 +69,41 @@
   
   miRE XmireUnlink(miRE mire, const char * msg, const char * fn, unsigned ln)
   {
  -    if (mire == NULL) return NULL;
  -
  -/*...@-modfilesys@*/
  -if (_mire_debug && msg != NULL)
  -fprintf(stderr, "--> mire %p -- %d %s at %s:%u\n", mire, mire->nrefs, msg, 
fn, ln);
  -/*...@=modfilesys@*/
  -
  -    mire->nrefs--;
  +    (void)rpmioUnlinkPoolItem((rpmioItem)mire, msg, fn, ln);
       return NULL;
   }
   
   miRE XmireLink(miRE mire, const char * msg, const char * fn, unsigned ln)
   {
  -    if (mire == NULL) return NULL;
  -    mire->nrefs++;
  -
  -/*...@-modfilesys@*/
  -if (_mire_debug && msg != NULL)
  -fprintf(stderr, "--> mire %p ++ %d %s at %s:%u\n", mire, mire->nrefs, msg, 
fn, ln);
  -/*...@=modfilesys@*/
  +    mire = (miRE) rpmioLinkPoolItem((rpmioItem)mire, msg, fn, ln);
  +    return mire;
  +}
   
  -    /*...@-refcounttrans@*/ return mire; /*...@=refcounttrans@*/
  +static void mireFini(void * _mire)
  +{
  +    miRE mire = _mire;
  +    (void) mireClean(mire);
   }
   
  -miRE mireFree(miRE mire)
  +/*...@unchecked@*/ /*...@only@*/ /*...@null@*/
  +rpmioPool _mirePool;
  +
  +miRE mireGetPool(rpmioPool pool)
   {
  -    if (mire == NULL)
  -     return NULL;
  +    miRE mire;
   
  -    if (mire->nrefs > 1)
  -     return mireUnlink(mire, "mireFree");
  +    if (_mirePool == NULL) {
  +     _mirePool = rpmioNewPool("mire", sizeof(*mire), -1, _mire_debug,
  +                     NULL, NULL, mireFini);
  +     pool = _mirePool;
  +    }
  +    return (miRE) rpmioGetPool(pool, sizeof(*mire));
  +}
   
  -    (void) mireClean(mire);
  -    (void) mireUnlink(mire, "mireFree");
  -/*...@-refcounttrans -usereleased @*/
  -    memset(mire, 0, sizeof(*mire));
  -    mire = _free(mire);
  -/*...@=refcounttrans =usereleased @*/
  +miRE mireFree(miRE mire)
  +{
  +    mireFini(mire);
  +    mire = (miRE)rpmioFreePoolItem((rpmioItem)mire, __FUNCTION__, __FILE__, 
__LINE__);
       return NULL;
   }
   
  @@ -116,7 +114,9 @@
        int i;
        for (i = 0; i < nmire; i++)
            (void) mireClean(mire + i);
  -     mire = _free(mire);
  +     /* XXX only the 1st element in the array has a usage mutex. */
  +     mire = xrealloc(mire, sizeof(*mire));
  +     mire = (miRE)rpmioFreePoolItem((rpmioItem)mire, __FUNCTION__, __FILE__, 
__LINE__);
       }
       return NULL;
   }
  @@ -124,10 +124,10 @@
   
   miRE mireNew(rpmMireMode mode, int tag)
   {
  -    miRE mire = xcalloc(1, sizeof(*mire));
  +    miRE mire = mireGetPool(_mirePool);
       mire->mode = mode;
       mire->tag = tag;
  -    return mireLink(mire,"mireNew");
  +    return mireLink(mire, "mireNew");
   }
   
   int mireSetCOptions(miRE mire, rpmMireMode mode, int tag, int options,
  @@ -493,14 +493,27 @@
   int mireAppend(rpmMireMode mode, int tag, const char * pattern,
                const unsigned char * table, miRE * mirep, int * nmirep)
   {
  -/*...@-refcounttrans@*/
  -    miRE mire = xrealloc((*mirep), ((*nmirep) + 1) * sizeof(*mire));
  -/*...@=refcounttrans@*/
  +    miRE mire;
       int xx;
   
  -    (*mirep) = mire;
  -    mire += (*nmirep)++;
  -    memset(mire, 0, sizeof(*mire));
  +    if (*mirep == NULL) {
  +     mire = mireGetPool(_mirePool);
  +     (*mirep) = mire;
  +    } else {
  +     void *use =  (*mirep)->_item.use;
  +     void *pool = (*mirep)->_item.pool;
  +
  +     /* XXX only the 1st element in the array has a usage mutex. */
  +     mire = xrealloc((*mirep), ((*nmirep) + 1) * sizeof(*mire));
  +     (*mirep) = mire;
  +     mire += (*nmirep);
  +     memset(mire, 0, sizeof(*mire));
  +        /* XXX ensure no segfault, copy the use/pool from 1st item. */
  +        mire->_item.use = use;
  +        mire->_item.pool = pool;
  +    }
  +
  +    (*nmirep)++;
       xx = mireSetCOptions(mire, mode, tag, 0, table);
       return mireRegcomp(mire, pattern);
   }
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/mire.h
  ============================================================================
  $ cvs diff -u -r1.28 -r1.29 mire.h
  --- rpm/rpmio/mire.h  27 Feb 2008 18:27:11 -0000      1.28
  +++ rpm/rpmio/mire.h  29 Mar 2009 22:42:24 -0000      1.29
  @@ -23,6 +23,9 @@
   extern int _mire_debug;
   /*...@=exportlocal@*/
   
  +/*...@unchecked@*/
  +extern rpmioPool _mirePool;
  +
   /**
    */
   /*...@unchecked@*/ /*...@null@*/ /*...@shared@*/
  @@ -49,6 +52,7 @@
   /** PCRE default: 0 */
   /*...@unchecked@*/
   extern int _mirePCREoptions;
  +
   /**
    */
   typedef /*...@abstract@*/ /*...@refcounted@*/ struct miRE_s * miRE;
  @@ -85,6 +89,7 @@
   /**
    */
   struct miRE_s {
  +    struct rpmioItem_s _item;        /*!< usage mutex and pool identifier. */
       rpmMireMode      mode;           /*!< pattern match mode */
   /*...@only@*/ /*...@relnull@*/
       const char *pattern;     /*!< pattern string */
  @@ -111,8 +116,10 @@
       int eoptions;    /*!< pcre_exec(3) options. */
       int notmatch;            /*!< non-zero: negative match, like "grep -v" */
       int tag;                 /*!< sort identifier (e.g. an rpmTag) */
  +#if defined(__LCLINT__)
   /*...@refs@*/
  -    int nrefs;                       /*!< Reference count. */
  +    int nrefs;                               /*!< (unused) keep splint happy 
*/
  +#endif
   };
   #endif       /* defined(_MIRE_INTERNAL) */
   
  @@ -128,6 +135,15 @@
   int mireClean(/*...@null@*/ miRE mire)
        /*...@modifies mire @*/;
   
  +/**
  + * Allocate a miRE container from the pool.
  + * @param pool               mire pool
  + * @return           miRE container
  + */
  +miRE mireGetPool(/*...@null@*/ rpmioPool pool)
  +        /*...@globals _mirePool, fileSystem @*/
  +        /*...@modifies pool, _mirePool, fileSystem @*/;
  +
   /*...@-exportlocal@*/
   /*...@null@*/
   miRE XmireUnlink (/*...@killref@*/ /*...@only@*/ /*...@null@*/ miRE mire,
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmio.c
  ============================================================================
  $ cvs diff -u -r1.176 -r1.177 rpmio.c
  --- rpm/rpmio/rpmio.c 29 Mar 2009 18:42:22 -0000      1.176
  +++ rpm/rpmio/rpmio.c 29 Mar 2009 22:42:24 -0000      1.177
  @@ -3126,6 +3126,7 @@
       extern rpmioPool _htPool;
   /*...@=shadow@*/
       extern rpmioPool _rpmmgPool;
  +    extern rpmioPool _mirePool;
   /*...@=nestedextern@*/
   
   #if defined(WITH_LUA)
  @@ -3142,6 +3143,7 @@
   #endif
       urlFreeCache();
   
  +    _mirePool = rpmioFreePool(_mirePool);
       _rpmmgPool = rpmioFreePool(_rpmmgPool);
       _htPool = rpmioFreePool(_htPool);
       _rpmiobPool = rpmioFreePool(_rpmiobPool);
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                rpm-cvs@rpm5.org

Reply via email to