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: 21-Mar-2009 15:21:22 Branch: rpm-5_1 Handle: 2009032114212101 Modified files: (Branch: rpm-5_1) rpm CHANGES rpm/rpmio librpmio.vers rpmurl.h url.c Log: - yarn: wire up urlFini, eliminate XurlFree. Summary: Revision Changes Path 1.2288.2.226+1 -0 rpm/CHANGES 2.63.2.14 +0 -1 rpm/rpmio/librpmio.vers 1.25.2.7 +2 -8 rpm/rpmio/rpmurl.h 1.51.2.8 +93 -89 rpm/rpmio/url.c ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/CHANGES ============================================================================ $ cvs diff -u -r1.2288.2.225 -r1.2288.2.226 CHANGES --- rpm/CHANGES 20 Mar 2009 22:04:00 -0000 1.2288.2.225 +++ rpm/CHANGES 21 Mar 2009 14:21:21 -0000 1.2288.2.226 @@ -1,4 +1,5 @@ 5.1.7 -> 5.1.8: + - jbj: yarn: wire up urlFini, eliminate XurlFree. - jbj: yarn: wire up fdFini, eliminate XfdFree. - jbj: url: fix: u->use clobbers the lock from the pool. - jbj: rpmds: fix: rpmdsDup needs to go through rpmdsGetPool() too. @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/librpmio.vers ============================================================================ $ cvs diff -u -r2.63.2.13 -r2.63.2.14 librpmio.vers --- rpm/rpmio/librpmio.vers 20 Mar 2009 22:04:01 -0000 2.63.2.13 +++ rpm/rpmio/librpmio.vers 21 Mar 2009 14:21:22 -0000 2.63.2.14 @@ -445,7 +445,6 @@ xstrncasecmp; xstrtolocale; XfdNew; - XurlFree; XurlNew; xzdio; yarnAbort; @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmurl.h ============================================================================ $ cvs diff -u -r1.25.2.6 -r1.25.2.7 rpmurl.h --- rpm/rpmio/rpmurl.h 20 Mar 2009 19:13:24 -0000 1.25.2.6 +++ rpm/rpmio/rpmurl.h 21 Mar 2009 14:21:22 -0000 1.25.2.7 @@ -114,7 +114,6 @@ #define RPMURL_DEBUG_IO 0x40000000 #define RPMURL_DEBUG_REFS 0x20000000 - /** * Create a URL control structure instance. * @param msg debugging identifier (unused) @@ -150,13 +149,8 @@ urlinfo urlFree( /*...@killref@*/ urlinfo u, const char * msg) /*...@globals fileSystem, internalState @*/ /*...@modifies u, fileSystem, internalState @*/; - -/** @todo Remove debugging entry from the ABI. */ -urlinfo XurlFree( /*...@killref@*/ urlinfo u, const char * msg, - const char * fn, unsigned ln) - /*...@globals fileSystem, internalState @*/ - /*...@modifies u, fileSystem, internalState @*/; -#define urlFree(_u, _msg) XurlFree(_u, _msg, __FILE__, __LINE__) +#define urlFree(_u, _msg) \ + ((urlinfo)rpmioFreePoolItem((rpmioItem)(_u), _msg, __FILE__, __LINE__)) /** * Free cached URL control structures. @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/url.c ============================================================================ $ cvs diff -u -r1.51.2.7 -r1.51.2.8 url.c --- rpm/rpmio/url.c 20 Mar 2009 22:04:01 -0000 1.51.2.7 +++ rpm/rpmio/url.c 21 Mar 2009 14:21:22 -0000 1.51.2.8 @@ -52,6 +52,68 @@ /*...@only@*/ /*...@null@*/ urlinfo *_url_cache = NULL; +static void urlFini(void * _u) + /*@ modifies *_u @*/ +{ + urlinfo u =_u; + int xx; + + if (u->ctrl) { +#ifndef NOTYET + void * fp = fdGetFp(u->ctrl); + if (fp) { + fdPush(u->ctrl, fpio, fp, -1); /* Push fpio onto stack */ + xx = Fclose(u->ctrl); + } else if (fdFileno(u->ctrl) >= 0) + xx = fdio->close(u->ctrl); +#else + xx = Fclose(u->ctrl); +#endif + +/*...@-usereleased@*/ + u->ctrl = (FD_t)rpmioFreePoolItem((rpmioItem)u->ctrl, "persist ctrl (urlFree)", __FILE__, __LINE__); + if (u->ctrl) + fprintf(stderr, _("warning: u %p ctrl %p nrefs != 0 (%s %s)\n"), + u, u->ctrl, (u->host ? u->host : ""), + (u->scheme ? u->scheme : "")); +/*...@=usereleased@*/ + } + if (u->data) { +#ifndef NOTYET + void * fp = fdGetFp(u->data); + if (fp) { + fdPush(u->data, fpio, fp, -1); /* Push fpio onto stack */ + xx = Fclose(u->data); + } else if (fdFileno(u->data) >= 0) + xx = fdio->close(u->data); +#else + xx = Fclose(u->ctrl); +#endif + +/*...@-usereleased@*/ + u->data = (FD_t)rpmioFreePoolItem((rpmioItem)u->data, "persist data (urlFree)", __FILE__, __LINE__); + if (u->data) + fprintf(stderr, _("warning: u %p data %p nrefs != 0 (%s %s)\n"), + u, u->data, (u->host ? u->host : ""), + (u->scheme ? u->scheme : "")); +/*...@=usereleased@*/ + } +#ifdef WITH_NEON + xx = davFree(u); +#endif + u->buf = _free(u->buf); + u->url = _free(u->url); + u->scheme = _free((void *)u->scheme); + u->user = _free((void *)u->user); + u->password = _free((void *)u->password); + u->host = _free((void *)u->host); + u->portstr = _free((void *)u->portstr); + u->query = _free(u->query); + u->fragment = _free(u->fragment); + u->proxyu = _free((void *)u->proxyu); + u->proxyh = _free((void *)u->proxyh); +} + /** */ /*...@unchecked@*/ @@ -67,7 +129,7 @@ if (_urlPool == NULL) { _urlPool = rpmioNewPool(" u", sizeof(*u), -1, _url_debug, - NULL, NULL, NULL); + NULL, NULL, urlFini); pool = _urlPool; } return (urlinfo) rpmioGetPool(pool, sizeof(*u)); @@ -76,9 +138,7 @@ urlinfo XurlNew(const char *msg, const char *fn, unsigned ln) { urlinfo u = urlGetPool(_urlPool); - if (u == NULL) /* XXX can't happen */ - return NULL; - memset(u, 0, sizeof(*u)); + u->proxyp = -1; u->port = -1; u->urltype = URL_IS_UNKNOWN; @@ -92,77 +152,6 @@ return (urlinfo) rpmioLinkPoolItem((rpmioItem)u, msg, fn, ln); } -urlinfo XurlFree(urlinfo u, const char *msg, const char *fn, unsigned ln) -{ - int xx; - - URLSANE(u); - yarnPossess(u->_item.use); -URLDBGREFS(0, (stderr, "--> url %p -- %ld %s at %s:%u\n", u, yarnPeekLock(u->_item.use), msg, fn, ln)); - if (yarnPeekLock(u->_item.use) <= 1L) { - if (u->ctrl) { -#ifndef NOTYET - void * fp = fdGetFp(u->ctrl); - if (fp) { - fdPush(u->ctrl, fpio, fp, -1); /* Push fpio onto stack */ - xx = Fclose(u->ctrl); - } else if (fdFileno(u->ctrl) >= 0) - xx = fdio->close(u->ctrl); -#else - xx = Fclose(u->ctrl); -#endif - - u->ctrl = rpmioFreePoolItem(u->ctrl, "persist ctrl (urlFree)", fn, ln); - /*...@-usereleased@*/ - if (u->ctrl) - fprintf(stderr, _("warning: u %p ctrl %p nrefs != 0 (%s %s)\n"), - u, u->ctrl, (u->host ? u->host : ""), - (u->scheme ? u->scheme : "")); - /*...@=usereleased@*/ - } - if (u->data) { -#ifndef NOTYET - void * fp = fdGetFp(u->data); - if (fp) { - fdPush(u->data, fpio, fp, -1); /* Push fpio onto stack */ - xx = Fclose(u->data); - } else if (fdFileno(u->data) >= 0) - xx = fdio->close(u->data); -#else - xx = Fclose(u->ctrl); -#endif - - u->data = rpmioFreePoolItem(u->data, "persist data (urlFree)", fn, ln); - /*...@-usereleased@*/ - if (u->data) - fprintf(stderr, _("warning: u %p data %p nrefs != 0 (%s %s)\n"), - u, u->data, (u->host ? u->host : ""), - (u->scheme ? u->scheme : "")); - /*...@=usereleased@*/ - } -#ifdef WITH_NEON - xx = davFree(u); -#endif - u->buf = _free(u->buf); - u->url = _free(u->url); - u->scheme = _free((void *)u->scheme); - u->user = _free((void *)u->user); - u->password = _free((void *)u->password); - u->host = _free((void *)u->host); - u->portstr = _free((void *)u->portstr); - u->query = _free(u->query); - u->fragment = _free(u->fragment); - u->proxyu = _free((void *)u->proxyu); - u->proxyh = _free((void *)u->proxyh); - u = (urlinfo) rpmioPutPool((rpmioItem)u); - return NULL; - } else { - yarnTwist(u->_item.use, BY, -1); - /*...@-refcounttrans -retal...@*/ return u; /*...@=refcounttrans =retal...@*/ - } - /*...@notreached@*/ -} - void urlFreeCache(void) { if (_url_cache) { @@ -173,11 +162,11 @@ if (_url_cache[i] == NULL) continue; yarnPossess(_url_cache[i]->_item.use); - fprintf(stderr, - _("warning: _url_cache[%d] %p nrefs(%ld) != 1 (%s %s)\n"), - i, _url_cache[i], yarnPeekLock(_url_cache[i]->_item.use), - (_url_cache[i]->host ? _url_cache[i]->host : ""), - (_url_cache[i]->scheme ? _url_cache[i]->scheme : "")); + fprintf(stderr, + _("warning: _url_cache[%d] %p nrefs(%ld) != 1 (%s %s)\n"), + i, _url_cache[i], yarnPeekLock(_url_cache[i]->_item.use), + (_url_cache[i]->host ? _url_cache[i]->host : ""), + (_url_cache[i]->scheme ? _url_cache[i]->scheme : "")); yarnRelease(_url_cache[i]->_item.use); } } @@ -256,6 +245,7 @@ /*...@-usereleased@*/ u = urlFree(u, "_url_cache (urlFind)"); /*...@=usereleased@*/ +assert(u != NULL); /* Zap proxy host and port in case they have been reset */ u->proxyp = -1; @@ -419,6 +409,21 @@ return urltype; } +/** + * Copy a URL, adding extra byte for the pesky trailing '/'. + */ +static const char * urlStrdup(const char * url) + /*...@*/ +{ + size_t nb = strlen(url); + char * t = xmalloc(nb + 1 + 1); + const char * nurl = t; + while (*url != '\0') + *t++ = *url++; + *t = '\0'; + return nurl; +} + /* * Split URL into components. The URL can look like * scheme://user:passw...@host:port/path @@ -437,14 +442,7 @@ if ((u = urlNew("urlSplit")) == NULL) return -1; - if ((myurl = xstrdup(url)) == NULL) { - u = urlFree(u, "urlSplit (error #1)"); - return -1; - } - - u->url = xstrdup(url); - u->urltype = urlIsURL(url); - + myurl = xstrdup(url); if ((se = strrchr(myurl, '#')) != NULL) { *se++ = '\0'; u->fragment = xstrdup(se); @@ -454,6 +452,9 @@ u->query = xstrdup(se); } + u->url = urlStrdup(myurl); /* XXX +1 byte for pesky trailing '/' */ + u->urltype = urlIsURL(myurl); + se = s = myurl; while (1) { /* Point to end of next item */ @@ -494,6 +495,7 @@ *f++ = '\0'; *fe++ = '\0'; } +assert(fe != NULL); /* XXX can't happen */ while (*fe && *fe != ':') fe++; if (*fe == ':') { *fe++ = '\0'; @@ -561,6 +563,7 @@ if (dest == NULL) return FTPERR_UNKNOWN; +/*...@-globs -m...@*/ /* Avoid including <rpmmacro.h> everywhere for now */ if (rpmExpandNumeric("%{?__urlgetfile:1}%{!?__urlgetfile:0}")) { result = rpmExpand("%{__urlgetfile ", url, " ", dest, "}", NULL); if (result != NULL && strcmp(result, "OK") == 0) @@ -572,8 +575,9 @@ result = _free(result); goto exit; } +/*...@=globs =m...@*/ - sfd = Fopen(url, "r"); + sfd = Fopen(url, "r.ufdio"); if (sfd == NULL || Ferror(sfd)) { rpmlog(RPMLOG_DEBUG, D_("failed to open %s: %s\n"), url, Fstrerror(sfd)); rc = FTPERR_UNKNOWN; @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org