cURL / Mailing Lists / curl-library / Single Mail


RE: CURL loops infinitely when cable is pulled out.

From: Sonia Subramanian <>
Date: Mon, 23 Apr 2007 15:20:22 -0700

It goes bad in ConnectionExists ->Curl_disconnect.
The free is called there.

-----Original Message-----
From: Sonia Subramanian
Sent: Monday, April 23, 2007 2:57 PM
To: 'libcurl development'
Cc: Charlotte Chang; Robert Spath; Shalu Jain
Subject: RE: CURL loops infinitely when cable is pulled out.


My code uses just resume from.
I think everywhere else resume from is converted to range even if range
was not specified.

The ConnectionExists executes after that

   * RESUME on a HTTP page is a tricky business. First, let's just check
   * 'range' isn't used, then set the range parameter and leave the
resume as
   * it is to inform about this situation for later use. We will then
   * "attempt" to resume, and if we're talking to a HTTP/1.1 (or later)
   * server, we will get the document resumed. If we talk to a HTTP/1.0
   * server, we just fail since we can't rewind the file writing from
   * this function.
  if(data->reqdata.resume_from) {
    if(!data->reqdata.use_range) {
      /* if it already was in use, we just skip this */
      data->reqdata.range = aprintf("%" FORMAT_OFF_T "-",
        return CURLE_OUT_OF_MEMORY;
      data->reqdata.rangestringalloc = TRUE; /* mark as allocated */
      data->reqdata.use_range = 1; /* switch on range usage */

   * Check the current list of connections to see if we can
   * re-use an already existing one or if we have to create a
   * new one.

  /* get a cloned copy of the SSL config situation stored in the
     connection struct */
  if(!Curl_clone_ssl_config(&data->set.ssl, &conn->ssl_config))

  /* reuse_fresh is TRUE if we are told to use a new connection by
force, but
     we only acknowledge this option if this is not a re-used connection
     already (which happens due to follow-location or during a HTTP
     authentication phase). */
  if(data->set.reuse_fresh && !data->state.this_is_a_follow)
    reuse = FALSE;
    reuse = ConnectionExists(data, conn, &conn_temp);

if(reuse) - has this taken care of.
The else part where my code path went does not.


-----Original Message-----
[] On Behalf Of Daniel Stenberg
Sent: Monday, April 23, 2007 2:10 PM
To: libcurl development
Cc: Charlotte Chang; Robert Spath; Shalu Jain
Subject: RE: CURL loops infinitely when cable is pulled out.

On Mon, 23 Apr 2007, Sonia Subramanian wrote:

> 3. In the next session a new CURL object is created and it does a
bunch of
> other things (like head requests) before actually requesting for the

> 4. It looks at the file information and and if the info says partial
it sets
> the CURL resume from, from that byte.

> 5. This worked well in the previous version that I used. (7.15.4).

> 6. In the new version, in this scenario I got http 416.

So why isn't the code around lib/url.c:3712 good enough? It checks if
is set (but not range) and then sets the internal reqdata.range variable
point to a suitable just created range string. What's wrong with that
string, or when does it go bad?

Does your code by any chance set _both_ resume_from and range?

  Commercial curl and libcurl Technical Support:
Received on 2007-04-24