cURL / Mailing Lists / curl-library / Single Mail

curl-library

Curl_done() is broken for pipelined connections

From: Dmitry Kurochkin <dmitry.kurochkin_at_gmail.com>
Date: Sun, 27 Jan 2008 15:18:38 +0300

Hello.

Another problem with pipelining. And I need advise on how to properly fix it.

I download a bunch of files with pipelining enabled. Sometimes server
sends "Connection: close". Connection should be closed and new one
created.

Connection is closed in Curl_done() function. It checks
conn->bits.done and does nothing if it is set. As I understand it
works fine without pipelining: we clear done flag when starting new
request, and then set it in Curl_done().

But in pipelining we (sometimes) get the following scenario:

1. Two requests sent, done flag is cleared.
2. First response comes, no "Connection: close" sent. Curl_done() is
called, connection is left intact, and done flag is set.
3. Second response comes with "Connection: close". Curl_done() is
closed (and it should call Curl_disconnect()) but done flag is already
set! And connection is not closed.
4. We start another request and it fails.

As a temporary solution I changed done check to the following:

  if(conn->bits.done && !conn->is_in_pipeline)

This fixes the problem but it looks like a hack. I would like to find
a proper solution and would like to here your thoughts on this.

Can we just remove bits.done? What so bad happens if we call
Curl_done() multiple times for the same connection?

Regards,
  Dmitry
Received on 2008-01-27