I am attaching the patch and a reproducer.  Unfortunately, the reproducer uses 
some external servers, so it cannot easily be used as an automatic test-case.

Kamil
From 201ea71ffedd767e3ba32c81c8b89249df9bac1c Mon Sep 17 00:00:00 2001
From: Kamil Dudka <[email protected]>
Date: Tue, 7 Jun 2011 15:57:13 +0200
Subject: [PATCH] disconnect: wipe out the keeps_speed time stamp

When closing a connection, the speedchecker's timestamp is now deleted
so that it cannot accidentally be used by a fresh connection on the same
handle when examining the transfer speed.

Bug: https://bugzilla.redhat.com/679709
---
 RELEASE-NOTES |    1 +
 lib/url.c     |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/RELEASE-NOTES b/RELEASE-NOTES
index c0f562e..0475f9f 100644
--- a/RELEASE-NOTES
+++ b/RELEASE-NOTES
@@ -23,6 +23,7 @@ This release includes the following bugfixes:
  o GnuTLS handshake: fix timeout
  o cyassl: build without filesystem
  o HTTPS over HTTP proxy using the multi interface
+ o speedcheck: invalid timeout event on a reused handle
 
 This release includes the following known bugs:
 
diff --git a/lib/url.c b/lib/url.c
index d37fe6d..c5b642f 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -2675,6 +2675,7 @@ CURLcode Curl_disconnect(struct connectdata *conn, bool dead_connection)
 
   conn_free(conn);
   data->state.current_conn = NULL;
+  Curl_speedinit(data);
 
   return CURLE_OK;
 }
-- 
1.7.4.4

#if 0
gcc -pedantic -Wall -Wextra -O0 -g bz679709.c -lcurl || exit $?
./a.out 13
exit $?
#endif

#include <curl/curl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

void isleep(unsigned delay)
{
    unsigned i;
    setbuf(stdout, NULL);
    printf("\nsleep(%d)", delay);

    for (i = 0; i < delay; ++i) {
        putchar('.');
        sleep(1);
    }

    putchar('\n');
    putchar('\n');
}

static size_t
sink(char *buffer, size_t size, size_t nitems, void *outstream)
{
    (void) buffer;
    (void) outstream;
    return size * nitems;
}

int main(int argc, char *argv[])
{
    int delay;
    CURLcode ret;
    CURL *hnd;

    if (2 != argc)
        return EXIT_FAILURE;

    delay = atoi(argv[1]);
    if (delay <= 0)
        return EXIT_FAILURE;

    curl_global_init(CURL_GLOBAL_DEFAULT);
    hnd = curl_easy_init();
    if (!hnd)
        return EXIT_FAILURE;

    curl_easy_setopt(hnd, CURLOPT_LOW_SPEED_LIMIT, 10L /* MiB */ << 20);
    curl_easy_setopt(hnd, CURLOPT_LOW_SPEED_TIME, 10L);
    curl_easy_setopt(hnd, CURLOPT_WRITEFUNCTION, sink);
    curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L);
    curl_easy_setopt(hnd, CURLOPT_URL, "http://mirror.karneval.cz\
/pub/linux/fedora/linux/releases/15/Fedora/i386/os/repodata/repomd.xml");

    if ((ret = curl_easy_perform(hnd)))
        return ret;

    isleep(delay);

    curl_easy_setopt(hnd, CURLOPT_URL, "ftp://ftp.linux.cz\
/pub/linux/fedora/linux/releases/15/Fedora/i386/os/repodata/repomd.xml");
    if ((ret = curl_easy_perform(hnd)))
        return ret;

    curl_easy_cleanup(hnd);
    curl_global_cleanup();
    return EXIT_SUCCESS;
}
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to