cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: [patch submission] libcurl 7.12.0 problems with hostname, proxy and keepalive

From: Bertrand Demiddelaer <bdemiddelaer_at_denyall.com>
Date: Mon, 26 Jul 2004 18:50:48 +0200

Daniel Stenberg wrote:
> On Fri, 23 Jul 2004, Bertrand Demiddelaer wrote:
>
>> Here's a global patch, including fixes for a few inconsistencies in
>> the debug messages, a fix to use the good hostname when doing
>> keepalive on a proxy, and the patch to have runtests.pl testing
>> valgrind version to put the good options...
>
>
> Can you please update the patch to work against CVS or a recent daily
> snapshot? I applied the cookie and runtests patches, but the url.c ones
> failed a lot.
>

I've just rebuilt the patch againt the last CVS snapshot (20040726),
here it is...

I've run the tests suite, and everything is OK, except for 6 tests which
were skipped (130, 131, 132, 133, 134, 165). For now, I didn't go
further in writing a test case for this fix...

--- lib/cookie.c.00 Mon May 24 09:54:26 2004
+++ lib/cookie.c Tue Jul 6 16:32:45 2004
@@ -254,7 +254,7 @@
               /* Received and skipped a cookie with a domain using too few
                  dots. */
               badcookie=TRUE; /* mark this as a bad cookie */
- infof(data, "skipped cookie with illegal dotcount domain: %s",
+ infof(data, "skipped cookie with illegal dotcount domain: %s\n",
                     whatptr);
             }
             else {
@@ -282,7 +282,7 @@
                    is not a domain to which the current host belongs. Mark as
                    bad. */
                 badcookie=TRUE;
- infof(data, "skipped cookie with bad tailmatch domain: %s",
+ infof(data, "skipped cookie with bad tailmatch domain: %s\n",
                       whatptr);
               }
             }
--- lib/url.c.00 Tue Jul 6 18:03:04 2004
+++ lib/url.c Tue Jul 6 18:27:55 2004
@@ -3019,10 +3019,17 @@
     conn->bits.user_passwd = old_conn->bits.user_passwd;
     conn->bits.proxy_user_passwd = old_conn->bits.proxy_user_passwd;
 
+ /* host can change, when doing keepalive with a proxy ! */
+ if (conn->bits.httpproxy) {
+ free(conn->host.rawalloc);
+ conn->host=old_conn->host;
+ }
+
     /* get the newly set value, not the old one */
     conn->bits.no_body = old_conn->bits.no_body;
 
- free(old_conn->host.rawalloc); /* free the newly allocated name buffer */
+ if (!conn->bits.httpproxy)
+ free(old_conn->host.rawalloc); /* free the newly allocated name buffer */
 
     free(conn->pathbuffer); /* free the newly allocated path pointer */
     conn->pathbuffer = old_conn->pathbuffer; /* use the old one */
@@ -3074,7 +3081,8 @@
     *in_connect = conn; /* return this instead! */
 
     infof(data, "Re-using existing connection! (#%ld) with host %s\n",
- conn->connectindex, conn->host.dispname);
+ conn->connectindex,
+ conn->bits.httpproxy?conn->proxy.dispname:conn->host.dispname);
   }
   else {
     /*
@@ -3159,6 +3167,9 @@
     hostaddr = NULL;
     conn->dns_entry = NULL; /* we don't connect now so we don't have any fresh
                                dns entry struct to point to */
+
+ if (conn->bits.httpproxy)
+ fix_hostname(conn, &conn->host);
   }
   else {
     /* this is a fresh connect */
@@ -3451,7 +3462,8 @@
   }
   else
     infof(data, "Connection #%ld to host %s left intact\n",
- conn->connectindex, conn->host.dispname);
+ conn->connectindex,
+ conn->bits.httpproxy?conn->proxy.dispname:conn->host.dispname);
 
   return result;
 }
--- tests/runtests.pl.00 Mon May 24 00:06:00 2004
+++ tests/runtests.pl Thu Jul 8 17:00:27 2004
@@ -1032,7 +1032,14 @@
     }
 
     if($valgrind) {
- $CMDLINE = "valgrind --leak-check=yes --logfile=log/valgrind$testnum -q $CMDLINE";
+ # since valgrind 2.1.x, '--tool' option is mandatory
+ # use it, if it is supported by the version installed on the system
+ my $valgrind_tool="";
+ system("valgrind --help 2>&1 | grep -- --tool > /dev/null 2>&1");
+ if (($? >> 8)==0) {
+ $valgrind_tool="--tool=memcheck ";
+ }
+ $CMDLINE = "valgrind ".$valgrind_tool."--leak-check=yes --logfile=log/valgrind$testnum -q $CMDLINE";
     }
 
     $CMDLINE .= "$cmdargs >>$STDOUT 2>>$STDERR";
Received on 2004-07-26