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: 29-Mar-2009 20:42:42 Branch: rpm-5_1 Handle: 2009032918424101 Modified files: (Branch: rpm-5_1) rpm/rpmio librpmio.vers poptIO.c rpmhash.h rpmio.c rpmiob.c rpmiotypes.h Log: - yarn: convert rpmiob to usage mutex with refcounts. Summary: Revision Changes Path 2.63.2.17 +0 -1 rpm/rpmio/librpmio.vers 1.24.2.5 +4 -0 rpm/rpmio/poptIO.c 1.5.2.4 +1 -1 rpm/rpmio/rpmhash.h 1.127.2.20 +6 -4 rpm/rpmio/rpmio.c 1.3.2.3 +26 -6 rpm/rpmio/rpmiob.c 1.15.2.3 +31 -6 rpm/rpmio/rpmiotypes.h ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/rpmio/librpmio.vers ============================================================================ $ cvs diff -u -r2.63.2.16 -r2.63.2.17 librpmio.vers --- rpm/rpmio/librpmio.vers 28 Mar 2009 17:44:36 -0000 2.63.2.16 +++ rpm/rpmio/librpmio.vers 29 Mar 2009 18:42:41 -0000 2.63.2.17 @@ -289,7 +289,6 @@ rpmiobAppend; rpmiobBuf; rpmiobEmpty; - rpmiobFree; rpmiobLen; rpmiobNew; rpmiobRTrim; @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/poptIO.c ============================================================================ $ cvs diff -u -r1.24.2.4 -r1.24.2.5 poptIO.c --- rpm/rpmio/poptIO.c 25 Mar 2009 19:56:56 -0000 1.24.2.4 +++ rpm/rpmio/poptIO.c 29 Mar 2009 18:42:41 -0000 1.24.2.5 @@ -61,6 +61,8 @@ /*...@unchecked@*/ extern int _rpmio_debug; /*...@unchecked@*/ +extern int _rpmiob_debug; +/*...@unchecked@*/ extern int _rpmsq_debug; /*...@unchecked@*/ extern int _tar_debug; @@ -396,6 +398,8 @@ N_("Debug PGP usage"), NULL}, { "rpmiodebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmio_debug, -1, 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}, { "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/rpmhash.h ============================================================================ $ cvs diff -u -r1.5.2.3 -r1.5.2.4 rpmhash.h --- rpm/rpmio/rpmhash.h 26 Mar 2009 20:10:03 -0000 1.5.2.3 +++ rpm/rpmio/rpmhash.h 29 Mar 2009 18:42:41 -0000 1.5.2.4 @@ -100,7 +100,7 @@ /** * Reference a hash table instance. - * @param ds hash table + * @param ht hash table * @return new hash table reference */ /*...@unused@*/ /*...@newref@*/ /*...@null@*/ @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmio.c ============================================================================ $ cvs diff -u -r1.127.2.19 -r1.127.2.20 rpmio.c --- rpm/rpmio/rpmio.c 28 Mar 2009 17:44:36 -0000 1.127.2.19 +++ rpm/rpmio/rpmio.c 29 Mar 2009 18:42:41 -0000 1.127.2.20 @@ -3098,13 +3098,14 @@ void rpmioClean(void) { /*...@-nestedextern@*/ - extern rpmioPool _digPool; - extern rpmioPool _xarPool; extern rpmioPool _urlPool; - extern rpmioPool _rpmmgPool; + extern rpmioPool _xarPool; + extern rpmioPool _digPool; + extern rpmioPool _rpmiobPool; /*...@-shadow@*/ extern rpmioPool _htPool; /*...@=shadow@*/ + extern rpmioPool _rpmmgPool; /*...@=nestedextern@*/ #if defined(WITH_LUA) @@ -3121,8 +3122,9 @@ #endif urlFreeCache(); - _htPool = rpmioFreePool(_htPool); _rpmmgPool = rpmioFreePool(_rpmmgPool); + _htPool = rpmioFreePool(_htPool); + _rpmiobPool = rpmioFreePool(_rpmiobPool); _digPool = rpmioFreePool(_digPool); _xarPool = rpmioFreePool(_xarPool); _urlPool = rpmioFreePool(_urlPool); @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmiob.c ============================================================================ $ cvs diff -u -r1.3.2.2 -r1.3.2.3 rpmiob.c --- rpm/rpmio/rpmiob.c 28 Mar 2009 17:44:36 -0000 1.3.2.2 +++ rpm/rpmio/rpmiob.c 29 Mar 2009 18:42:42 -0000 1.3.2.3 @@ -10,18 +10,38 @@ /*...@unchecked@*/ size_t _rpmiob_chunk = 1024; -rpmiob rpmiobFree(rpmiob iob) +/*...@unchecked@*/ +int _rpmiob_debug; + +static void rpmiobFini(void * _iob) { - if (iob != NULL) { + rpmiob iob = _iob; + iob->b = _free(iob->b); - iob = _free(iob); + iob->blen = 0; + iob->allocated = 0; +} + +/*...@unchecked@*/ /*...@only@*/ /*...@null@*/ +rpmioPool _rpmiobPool; + +static rpmiob rpmiobGetPool(/*...@null@*/ rpmioPool pool) + /*...@globals _rpmiobPool, fileSystem @*/ + /*...@modifies pool, _rpmiobPool, fileSystem @*/ +{ + rpmiob iob; + + if (_rpmiobPool == NULL) { + _rpmiobPool = rpmioNewPool("iob", sizeof(*iob), -1, _rpmiob_debug, + NULL, NULL, rpmiobFini); + pool = _rpmiobPool; } - return NULL; + return (rpmiob) rpmioGetPool(pool, sizeof(*iob)); } rpmiob rpmiobNew(size_t len) { - rpmiob iob = xcalloc(1, sizeof(*iob)); + rpmiob iob = rpmiobGetPool(_rpmiobPool); if (len == 0) len = _rpmiob_chunk; iob->allocated = len; @@ -142,7 +162,7 @@ if (rc == 0) { if (iobp != NULL) { /* XXX use rpmiobNew() if/when lazy iop->b alloc is implemented. */ - rpmiob iob = xcalloc(1, sizeof(*iob)); + rpmiob iob = rpmiobGetPool(_rpmiobPool); iob->b = b; iob->blen = blen; iob->allocated = blen; @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmiotypes.h ============================================================================ $ cvs diff -u -r1.15.2.2 -r1.15.2.3 rpmiotypes.h --- rpm/rpmio/rpmiotypes.h 28 Mar 2009 17:44:36 -0000 1.15.2.2 +++ rpm/rpmio/rpmiotypes.h 29 Mar 2009 18:42:42 -0000 1.15.2.3 @@ -138,9 +138,10 @@ /** \ingroup rpmio */ struct rpmiob_s{ - uint8_t * b; /*!< data octects. */ - size_t blen; /*!< no. of octets used. */ - size_t allocated; /*!< no. of octets allocated. */ + struct rpmioItem_s _item; /*!< usage mutex and pool identifier. */ + uint8_t * b; /*!< data octects. */ + size_t blen; /*!< no. of octets used. */ + size_t allocated; /*!< no. of octets allocated. */ }; #endif @@ -241,13 +242,37 @@ /*...@modifies *str @*/; /** - * Destroy an I/O buffer. + * Unreference a I/O buffer instance. + * @param iob hash table + * @return NULL if free'd + */ +/*...@unused@*/ /*...@null@*/ +rpmiob rpmiobUnlink (/*...@killref@*/ /*...@null@*/ rpmiob iob) + /*...@modifies iob @*/; +#define rpmiobUnlink(_iob) \ + ((rpmiob)rpmioUnlinkPoolItem((rpmioItem)(_iob), __FUNCTION__, __FILE__, __LINE__)) + +/** + * Reference a I/O buffer instance. * @param iob I/O buffer - * @return NULL always + * @return new I/O buffer reference + */ +/*...@unused@*/ /*...@newref@*/ /*...@null@*/ +rpmiob rpmiobLink (/*...@null@*/ rpmiob iob) + /*...@modifies iob @*/; +#define rpmiobLink(_iob) \ + ((rpmiob)rpmioLinkPoolItem((rpmioItem)(_iob), __FUNCTION__, __FILE__, __LINE__)) + +/** + * Destroy a I/O buffer instance. + * @param iob I/O buffer + * @return NULL on last dereference */ /*...@null@*/ -rpmiob rpmiobFree(/*...@only@*/ /*...@null@*/ rpmiob iob) +rpmiob rpmiobFree( /*...@only@*/ rpmiob iob) /*...@modifies iob @*/; +#define rpmiobFree(_iob) \ + ((rpmiob)rpmioFreePoolItem((rpmioItem)(_iob), __FUNCTION__, __FILE__, __LINE__)) /** * Create an I/O buffer. @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org