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:   11-Apr-2009 18:34:41
  Branch: rpm-5_1                          Handle: 2009041116344001

  Modified files:           (Branch: rpm-5_1)
    rpm                     CHANGES
    rpm/rpmio               poptIO.c rpmio.c rpmlua.c rpmlua.h

  Log:
    - yarn: convert rpmluav to usage mutex with refcounts
    - yarn: convert rpmlua to usage mutex with refcounts

  Summary:
    Revision    Changes     Path
    1.2288.2.292+2  -0      rpm/CHANGES
    1.24.2.8    +6  -0      rpm/rpmio/poptIO.c
    1.127.2.26  +8  -0      rpm/rpmio/rpmio.c
    2.52.2.9    +73 -27     rpm/rpmio/rpmlua.c
    2.12.2.2    +35 -30     rpm/rpmio/rpmlua.h
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.2288.2.291 -r1.2288.2.292 CHANGES
  --- rpm/CHANGES       11 Apr 2009 14:50:59 -0000      1.2288.2.291
  +++ rpm/CHANGES       11 Apr 2009 16:34:40 -0000      1.2288.2.292
  @@ -1,4 +1,6 @@
   5.1.7 -> 5.1.8:
  +    - jbj: yarn: convert rpmluav to usage mutex with refcounts
  +    - jbj: yarn: convert rpmlua to usage mutex with refcounts
       - jbj: popt: remove retrofits for popt < 1.14. use popt internal if 
needed.
       - jbj: mire: teardown for platpat on exit needs to be done in order.
       - jbj: rpmwget: move to tools.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/poptIO.c
  ============================================================================
  $ cvs diff -u -r1.24.2.7 -r1.24.2.8 poptIO.c
  --- rpm/rpmio/poptIO.c        6 Apr 2009 00:20:11 -0000       1.24.2.7
  +++ rpm/rpmio/poptIO.c        11 Apr 2009 16:34:41 -0000      1.24.2.8
  @@ -63,6 +63,8 @@
   /*...@unchecked@*/
   extern int _rpmiob_debug;
   /*...@unchecked@*/
  +extern int _rpmlua_debug;
  +/*...@unchecked@*/
   extern int _rpmsq_debug;
   /*...@unchecked@*/
   extern int _tar_debug;
  @@ -400,6 +402,10 @@
        N_("Debug rpmio I/O"), NULL},
    { "rpmiobdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, 
&_rpmiob_debug, -1,
        N_("Debug rpmio I/O buffers"), NULL},
  +#ifdef WITH_LUA
  + { "rpmluadebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, 
&_rpmlua_debug, -1,
  +     N_("Debug embedded Lua interpreter"), NULL},
  +#endif
    { "rpmmgdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmmg_debug, 
-1,
        N_("Debug rpmmg magic"), NULL},
    { "rpmsqdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmsq_debug, 
-1,
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmio.c
  ============================================================================
  $ cvs diff -u -r1.127.2.25 -r1.127.2.26 rpmio.c
  --- rpm/rpmio/rpmio.c 6 Apr 2009 00:20:11 -0000       1.127.2.25
  +++ rpm/rpmio/rpmio.c 11 Apr 2009 16:34:41 -0000      1.127.2.26
  @@ -3147,6 +3147,10 @@
   /*...@=shadow@*/
       extern rpmioPool _rpmmgPool;
   /*...@=nestedextern@*/
  +#if defined(WITH_LUA)
  +    extern rpmioPool _rpmluavPool;
  +    extern rpmioPool _rpmluaPool;
  +#endif
   
   #if defined(WITH_LUA)
       (void) rpmluaFree(NULL);
  @@ -3162,6 +3166,10 @@
   #endif
       urlFreeCache();
   
  +#if defined(WITH_LUA)
  +    _rpmluavPool = rpmioFreePool(_rpmluavPool);
  +    _rpmluaPool = rpmioFreePool(_rpmluaPool);
  +#endif
       _mirePool = rpmioFreePool(_mirePool);
       _rpmmgPool = rpmioFreePool(_rpmmgPool);
       _htPool = rpmioFreePool(_htPool);
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmlua.c
  ============================================================================
  $ cvs diff -u -r2.52.2.8 -r2.52.2.9 rpmlua.c
  --- rpm/rpmio/rpmlua.c        2 Apr 2009 18:48:39 -0000       2.52.2.8
  +++ rpm/rpmio/rpmlua.c        11 Apr 2009 16:34:41 -0000      2.52.2.9
  @@ -37,6 +37,9 @@
   
   /*...@access rpmiob @*/
   
  +/*...@unchecked@*/
  +int _rpmlua_debug = 0;
  +
   #if !defined(HAVE_VSNPRINTF)
   static inline int vsnprintf(char * buf, /*...@unused@*/ size_t nb,
                            const char * fmt, va_list ap)
  @@ -75,10 +78,46 @@
   /*...@=globstate@*/
   }
   
  +static void rpmluaFini(void * _lua)
  +     /*...@globals globalLuaState @*/
  +     /*...@modifies globalLuaState @*/
  +{
  +    rpmlua lua = _lua;
  +
  +    if (lua->L) lua_close(lua->L);
  +    lua->L = NULL;
  +    lua->printbuf = _free(lua->printbuf);
  +}
  +
  +/*...@unchecked@*/ /*...@only@*/ /*...@null@*/
  +rpmioPool _rpmluaPool;
  +
  +static rpmlua rpmluaGetPool(/*...@null@*/ rpmioPool pool)
  +        /*...@globals _rpmluaPool, fileSystem @*/
  +        /*...@modifies pool, _rpmluaPool, fileSystem @*/
  +{
  +    rpmlua lua;
  +
  +    if (_rpmluaPool == NULL) {
  +        _rpmluaPool = rpmioNewPool("lua", sizeof(*lua), -1, _rpmlua_debug,
  +                        NULL, NULL, rpmluaFini);
  +        pool = _rpmluaPool;
  +    }
  +    return (rpmlua) rpmioGetPool(pool, sizeof(*lua));
  +}
  +
  +void *rpmluaFree(rpmlua lua)
  +{
  +    if (lua == NULL) lua = globalLuaState;
  +    (void)rpmioFreePoolItem((rpmioItem)lua, __FUNCTION__, __FILE__, 
__LINE__);
  +    if (lua == globalLuaState) globalLuaState = NULL;
  +    return NULL;
  +}
  +
   /*...@-globs -m...@*/        /* XXX hide rpmGlobalMacroContext mods for now. 
*/
  -rpmlua rpmluaNew()
  +rpmlua rpmluaNew(void)
   {
  -    rpmlua lua = (rpmlua) xcalloc(1, sizeof(*lua));
  +    rpmlua lua = rpmluaGetPool(_rpmluaPool);
       lua_State *L = lua_open();
       /*...@-readonlytrans -nullassign @*/
       /*...@observer@*/ /*...@unchecked@*/
  @@ -102,6 +141,13 @@
        {"rex_pcre", luaopen_rex_pcre},
        {"uuid", luaopen_uuid},
        {"wrs", luaopen_wrs},
  +#ifdef       USE_LUA_CRYPTO          /* XXX external lua modules instead. */
  +     {"crypto", luaopen_crypto},
  +     {"lxp", luaopen_lxp},
  +#endif
  +#ifdef       USE_LUA_SOCKET          /* XXX external lua modules instead. */
  +     {"socket", luaopen_socket_core},
  +#endif
        {"local", luaopen_local},
   #endif
        {"rpm", luaopen_rpm},
  @@ -123,7 +169,7 @@
   /*...@=noeffectuncon@*/
       }
       {        const char * _lua_path = rpmGetPath(rpmluaPath, NULL);
  -     if (_lua_path != NULL) {
  +     if (_lua_path != NULL) {
            lua_pushliteral(L, "LUA_PATH");
            lua_pushstring(L, _lua_path);
            _lua_path = _free(_lua_path);
  @@ -178,27 +224,10 @@
       }
       path_buf = _free(path_buf);
   
  -    return lua;
  +    return ((rpmlua)rpmioLinkPoolItem((rpmioItem)lua, __FUNCTION__, 
__FILE__, __LINE__));
   }
   /*...@=globs =m...@*/
   
  -void *rpmluaFree(rpmlua lua)
  -     /*...@globals globalLuaState @*/
  -     /*...@modifies globalLuaState @*/
  -{
  -    if (lua == NULL)
  -     lua = globalLuaState;
  -    if (lua) {
  -     if (lua->L) lua_close(lua->L);
  -     lua->printbuf = _free(lua->printbuf);
  -     if (lua == globalLuaState) globalLuaState = NULL;
  -     lua = _free(lua);
  -    }
  -/*...@-globstate@*/
  -    return NULL;
  -/*...@=globstate@*/
  -}
  -
   void rpmluaSetData(rpmlua _lua, const char *key, const void *data)
   {
       INITSTATE(_lua, lua);
  @@ -437,16 +466,33 @@
       lua_pop(lua->L, 1);
   }
   
  -rpmluav rpmluavNew(void)
  +void *rpmluavFree(rpmluav var)
   {
  -    rpmluav var = (rpmluav) xcalloc(1, sizeof(*var));
  -    return var;
  +    (void)rpmioFreePoolItem((rpmioItem)var, __FUNCTION__, __FILE__, 
__LINE__);
  +    return NULL;
   }
   
  -void *rpmluavFree(rpmluav var)
  +/*...@unchecked@*/ /*...@only@*/ /*...@null@*/
  +rpmioPool _rpmluavPool;
  +
  +static rpmluav rpmluavGetPool(/*...@null@*/ rpmioPool pool)
  +        /*...@globals _rpmluavPool, fileSystem @*/
  +        /*...@modifies pool, _rpmluavPool, fileSystem @*/
   {
  -    var = _free(var);
  -    return NULL;
  +    rpmluav luav;
  +
  +    if (_rpmluavPool == NULL) {
  +        _rpmluavPool = rpmioNewPool("luav", sizeof(*luav), -1, _rpmlua_debug,
  +                        NULL, NULL, NULL);
  +        pool = _rpmluavPool;
  +    }
  +    return (rpmluav) rpmioGetPool(pool, sizeof(*luav));
  +}
  +
  +rpmluav rpmluavNew(void)
  +{
  +    rpmluav var = rpmluavGetPool(_rpmluavPool);
  +    return ((rpmluav)rpmioLinkPoolItem((rpmioItem)var, __FUNCTION__, 
__FILE__, __LINE__));
   }
   
   void rpmluavSetListMode(rpmluav var, int flag)
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmlua.h
  ============================================================================
  $ cvs diff -u -r2.12.2.1 -r2.12.2.2 rpmlua.h
  --- rpm/rpmio/rpmlua.h        27 Oct 2008 04:07:47 -0000      2.12.2.1
  +++ rpm/rpmio/rpmlua.h        11 Apr 2009 16:34:41 -0000      2.12.2.2
  @@ -13,6 +13,7 @@
   #include <lua.h>
   
   struct rpmlua_s {
  +    struct rpmioItem_s _item;        /*!< usage mutex and pool identifier. */
       lua_State *L;
       int pushsize;
       int storeprint;
  @@ -23,6 +24,7 @@
   };
   
   struct rpmluav_s {
  +    struct rpmioItem_s _item;        /*!< usage mutex and pool identifier. */
       rpmluavType keyType;
       rpmluavType valueType;
       union {
  @@ -47,10 +49,10 @@
   extern "C" {
   #endif
   
  -/*...@unchecked@*/
  +/*...@unchecked@*/ /*...@observer@*/
   extern const char * rpmluaFiles;
   
  -/*...@unchecked@*/
  +/*...@unchecked@*/ /*...@observer@*/
   extern const char * rpmluaPath;
   
   /*...@-exportlocal@*/
  @@ -62,66 +64,69 @@
        /*...@globals fileSystem, internalState @*/
        /*...@modifies fileSystem, internalState @*/;
   /*...@=exportlocal@*/
  +/*...@null@*/
   void *rpmluaFree(/*...@only@*/ rpmlua lua)
        /*...@globals internalState @*/
        /*...@modifies lua, internalState @*/;
   
  -int rpmluaCheckScript(/*...@null@*/ rpmlua lua, const char *script,
  +int rpmluaCheckScript(/*...@null@*/ rpmlua _lua, const char *script,
                      /*...@null@*/ const char *name)
        /*...@globals fileSystem, internalState @*/
  -     /*...@modifies lua, fileSystem, internalState @*/;
  -int rpmluaRunScript(/*...@null@*/ rpmlua lua, const char *script,
  +     /*...@modifies _lua, fileSystem, internalState @*/;
  +int rpmluaRunScript(/*...@null@*/ rpmlua _lua, const char *script,
                    /*...@null@*/ const char *name)
        /*...@globals fileSystem, internalState @*/
  -     /*...@modifies lua, fileSystem, internalState @*/;
  +     /*...@modifies _lua, fileSystem, internalState @*/;
   /*...@-exportlocal@*/
  -int rpmluaRunScriptFile(/*...@null@*/ rpmlua lua, const char *filename)
  +int rpmluaRunScriptFile(/*...@null@*/ rpmlua _lua, const char *filename)
        /*...@globals fileSystem, internalState @*/
  -     /*...@modifies lua, fileSystem, internalState @*/;
  +     /*...@modifies _lua, fileSystem, internalState @*/;
   /*...@=exportlocal@*/
  -void rpmluaInteractive(/*...@null@*/ rpmlua lua)
  +void rpmluaInteractive(/*...@null@*/ rpmlua _lua)
        /*...@globals fileSystem, internalState @*/
  -     /*...@modifies lua, fileSystem, internalState @*/;
  +     /*...@modifies _lua, fileSystem, internalState @*/;
   
  -void *rpmluaGetData(/*...@null@*/ rpmlua lua, const char *key)
  +/*...@null@*/
  +void *rpmluaGetData(/*...@null@*/ rpmlua _lua, const char *key)
        /*...@globals fileSystem, internalState @*/
  -     /*...@modifies lua, fileSystem, internalState @*/;
  +     /*...@modifies _lua, fileSystem, internalState @*/;
   /*...@-exportlocal@*/
  -void rpmluaSetData(/*...@null@*/ rpmlua lua, const char *key, const void 
*data)
  +void rpmluaSetData(/*...@null@*/ rpmlua _lua, const char *key, const void 
*data)
        /*...@globals fileSystem, internalState @*/
  -     /*...@modifies lua, fileSystem, internalState @*/;
  +     /*...@modifies _lua, fileSystem, internalState @*/;
   /*...@=exportlocal@*/
   
   /*...@exposed@*/
  -const char *rpmluaGetPrintBuffer(/*...@null@*/ rpmlua lua)
  +const char *rpmluaGetPrintBuffer(/*...@null@*/ rpmlua _lua)
        /*...@globals fileSystem, internalState @*/
  -     /*...@modifies lua, fileSystem, internalState @*/;
  -void rpmluaSetPrintBuffer(/*...@null@*/ rpmlua lua, int flag)
  +     /*...@modifies _lua, fileSystem, internalState @*/;
  +void rpmluaSetPrintBuffer(/*...@null@*/ rpmlua _lua, int flag)
        /*...@globals fileSystem, internalState @*/
  -     /*...@modifies lua, fileSystem, internalState @*/;
  +     /*...@modifies _lua, fileSystem, internalState @*/;
   
  -void rpmluaGetVar(/*...@null@*/ rpmlua lua, rpmluav var)
  +void rpmluaGetVar(/*...@null@*/ rpmlua _lua, rpmluav var)
        /*...@globals fileSystem, internalState @*/
  -     /*...@modifies lua, var, fileSystem, internalState @*/;
  -void rpmluaSetVar(/*...@null@*/ rpmlua lua, rpmluav var)
  +     /*...@modifies _lua, var, fileSystem, internalState @*/;
  +void rpmluaSetVar(/*...@null@*/ rpmlua _lua, rpmluav var)
        /*...@globals fileSystem, internalState @*/
  -     /*...@modifies lua, var, fileSystem, internalState @*/;
  -void rpmluaDelVar(/*...@null@*/ rpmlua lua, const char *key, ...)
  +     /*...@modifies _lua, var, fileSystem, internalState @*/;
  +void rpmluaDelVar(/*...@null@*/ rpmlua _lua, const char *key, ...)
        /*...@globals fileSystem, internalState @*/
  -     /*...@modifies lua, fileSystem, internalState @*/;
  -int rpmluaVarExists(/*...@null@*/ rpmlua lua, const char *key, ...)
  +     /*...@modifies _lua, fileSystem, internalState @*/;
  +int rpmluaVarExists(/*...@null@*/ rpmlua _lua, const char *key, ...)
        /*...@globals fileSystem, internalState @*/
  -     /*...@modifies lua, fileSystem, internalState @*/;
  -void rpmluaPushTable(/*...@null@*/ rpmlua lua, const char *key, ...)
  +     /*...@modifies _lua, fileSystem, internalState @*/;
  +void rpmluaPushTable(/*...@null@*/ rpmlua _lua, const char *key, ...)
        /*...@globals fileSystem, internalState @*/
  -     /*...@modifies lua, fileSystem, internalState @*/;
  -void rpmluaPop(/*...@null@*/ rpmlua lua)
  +     /*...@modifies _lua, fileSystem, internalState @*/;
  +void rpmluaPop(/*...@null@*/ rpmlua _lua)
        /*...@globals fileSystem, internalState @*/
  -     /*...@modifies lua, fileSystem, internalState @*/;
  +     /*...@modifies _lua, fileSystem, internalState @*/;
   
   /*...@only@*/
   rpmluav rpmluavNew(void)
        /*...@*/;
  +/*...@null@*/
   void * rpmluavFree(/*...@only@*/ rpmluav var)
        /*...@modifes var @*/;
   void rpmluavSetListMode(rpmluav var, int flag)
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                rpm-cvs@rpm5.org

Reply via email to