summaryrefslogtreecommitdiff
path: root/rpmio
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2004-11-08 17:10:36 +0000
committerjbj <devnull@localhost>2004-11-08 17:10:36 +0000
commit04a779db7250865087dad5108e2dff3103419e71 (patch)
treef389597ad2f858bff015d294bbe31e1ccb0f2016 /rpmio
parent42554d5d08e4f4d4252a54fe38ad5ad4e00d2493 (diff)
downloadrpm-04a779db7250865087dad5108e2dff3103419e71.tar.gz
rpm-04a779db7250865087dad5108e2dff3103419e71.tar.bz2
rpm-04a779db7250865087dad5108e2dff3103419e71.zip
Functional https:// with Keepalive on.
CVS patchset: 7554 CVS date: 2004/11/08 17:10:36
Diffstat (limited to 'rpmio')
-rw-r--r--rpmio/rpmdav.c5
-rw-r--r--rpmio/rpmio.c55
-rw-r--r--rpmio/tget.c8
3 files changed, 47 insertions, 21 deletions
diff --git a/rpmio/rpmdav.c b/rpmio/rpmdav.c
index 5284dca48..686fb077e 100644
--- a/rpmio/rpmdav.c
+++ b/rpmio/rpmdav.c
@@ -258,6 +258,7 @@ static int davInit(const char * url, urlinfo * uret)
/* HACK: oneshots should be done Somewhere Else Instead. */
/*@-noeffect@*/
xx = (_dav_debug ? NE_DBG_HTTP : 0);
+ xx = 0; /* HACK */
ne_debug_init(stderr, xx); /* XXX oneshot? */
/*@=noeffect@*/
xx = ne_sock_init(); /* XXX oneshot? */
@@ -796,6 +797,7 @@ static int my_result(const char * msg, int ret, FILE * fp)
return ret;
}
+#ifdef DYING
static void hexdump(unsigned char * buf, ssize_t len)
/*@*/
{
@@ -809,6 +811,7 @@ static void hexdump(unsigned char * buf, ssize_t len)
}
fprintf(stderr, "\n");
}
+#endif
static void davAcceptRanges(void * userdata, const char * value)
{
@@ -1023,7 +1026,9 @@ ssize_t davRead(void * cookie, /*@out@*/ char * buf, size_t count)
if (_dav_debug) {
fprintf(stderr, "*** davRead(%p,%p,0x%x) rc 0x%x\n", cookie, buf, count, (unsigned)rc);
+#ifdef DYING
hexdump(buf, rc);
+#endif
}
return rc;
diff --git a/rpmio/rpmio.c b/rpmio/rpmio.c
index 0704c4c4f..aa6b1a6d7 100644
--- a/rpmio/rpmio.c
+++ b/rpmio/rpmio.c
@@ -1890,13 +1890,13 @@ int ufdClose( /*@only@*/ void * cookie)
}
/*
- * Normal FTP has 4 refs on the data fd:
+ * Non-error FTP has 4 refs on the data fd:
* "persist data (ufdOpen FTP)" rpmio.c:888
* "grab data (ufdOpen FTP)" rpmio.c:892
* "open data (ftpReq)" ftp.c:633
* "fopencookie" rpmio.c:1507
*
- * Normal FTP has 5 refs on the ctrl fd:
+ * Non-error FTP has 5 refs on the ctrl fd:
* "persist ctrl" url.c:176
* "grab ctrl (urlConnect FTP)" rpmio.c:404
* "open ctrl" ftp.c:504
@@ -1941,20 +1941,13 @@ int ufdClose( /*@only@*/ void * cookie)
if (_ftp_debug)
fprintf(stderr, "-> \r\n");
(void) fdWrite(fd, "\r\n", sizeof("\r\n")-1);
- /* HACK: flimsy wiring for davClose */
+ /* HACK: flimsy wiring for davWrite */
if (!strcmp(u->scheme, "https"))
rc = davResp(u, fd, NULL);
else
rc = httpResp(u, fd, NULL);
}
- if (fd == u->ctrl)
- fd = u->ctrl = fdFree(fd, "open data (ufdClose HTTP persist ctrl)");
- else if (fd == u->data)
- fd = u->data = fdFree(fd, "open data (ufdClose HTTP persist data)");
- else
- fd = fdFree(fd, "open data (ufdClose HTTP)");
-
/*
* HTTP has 4 (or 5 if persistent malloc) refs on the fd:
* "persist ctrl" url.c:177
@@ -1964,6 +1957,13 @@ fprintf(stderr, "-> \r\n");
* "open data (httpReq)" ftp.c:435
*/
+ if (fd == u->ctrl)
+ fd = u->ctrl = fdFree(fd, "open data (ufdClose HTTP persist ctrl)");
+ else if (fd == u->data)
+ fd = u->data = fdFree(fd, "open data (ufdClose HTTP persist data)");
+ else
+ fd = fdFree(fd, "open data (ufdClose HTTP)");
+
/* XXX if not using libio, lose the fp from fpio */
{ FILE * fp;
/*@+voidabstract -nullpass@*/
@@ -1973,15 +1973,14 @@ fprintf(stderr, "-> \r\n");
/*@=voidabstract =nullpass@*/
}
- if (fd->persist && u->httpVersion &&
- (fd == u->ctrl || fd == u->data) && fd->bytesRemain == 0) {
- fd->contentLength = fd->bytesRemain = -1;
- if (!strcmp(u->scheme, "http"))
- return 0;
- /* HACK: flimsy wiring for davClose */
- } else {
- fd->contentLength = fd->bytesRemain = -1;
- }
+ /* If content remains, then don't persist. */
+ if (fd->bytesRemain > 0)
+ fd->persist = 0;
+ fd->contentLength = fd->bytesRemain = -1;
+
+ /* If persisting, then Fclose will juggle refcounts. */
+ if (fd->persist && (fd == u->ctrl || fd == u->data))
+ return 0;
}
}
return fdClose(fd);
@@ -2775,6 +2774,8 @@ DBGIO(fd, (stderr, "==> Fclose(%p) %s\n", (fd ? fd : NULL), fdbg(fd)));
fd->fps[fd->nfps-1].fp == fp &&
(fd->fps[fd->nfps-1].fdno >= 0 || fd->req != NULL))
{
+ int hadreqpersist = (fd->req != NULL);
+
if (fp)
rc = fflush(fp);
fd->nfps--;
@@ -2784,10 +2785,22 @@ DBGIO(fd, (stderr, "==> Fclose(%p) %s\n", (fd ? fd : NULL), fdbg(fd)));
/*@-usereleased@*/
if (fdGetFdno(fd) >= 0)
break;
+ if (!fd->persist)
+ hadreqpersist = 0;
fdSetFp(fd, NULL);
fd->nfps++;
- if (fp)
- rc = fclose(fp);
+ if (fp) {
+ /* HACK: flimsy Keepalive wiring. */
+ if (hadreqpersist) {
+ fd->nfps--;
+ fdSetFp(fd, fp);
+ (void) fdClose(fd);
+ fdSetFp(fd, NULL);
+ fd->nfps++;
+ (void) fdClose(fd);
+ } else
+ rc = fclose(fp);
+ }
fdPop(fd);
if (noLibio)
fdSetFp(fd, NULL);
diff --git a/rpmio/tget.c b/rpmio/tget.c
index 2eb3d6d1d..a97871ffd 100644
--- a/rpmio/tget.c
+++ b/rpmio/tget.c
@@ -73,14 +73,22 @@ _ftp_debug = -1;
_dav_debug = -1;
#if 0
readFile(dirpath);
+#endif
+#if 0
+ readFile(ftppath);
+ readFile(ftppath);
readFile(ftppath);
+#endif
+#if 0
readFile(httppath);
readFile(httppath);
readFile(httppath);
#endif
+#if 1
readFile(httpspath);
readFile(httpspath);
readFile(httpspath);
+#endif
/*@i@*/ urlFreeCache();