cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl_easy_cleanup and curl-multi

From: <Zibiao.Wei_at_atxinc.com>
Date: Wed, 8 Jun 2005 15:07:41 -0400

I am using version 7.14.0.

I figured out my problem. I have used the HEADERFUNCTION call back. The
easy handle first time has an ftp connection, and the second time has an
http connection. Surprisingly the ftp connection is still alive when I
call curl_easy_cleanup. It sends a close command to the ftp server and
activate my HEADERFUNCTION, which at this moment tries to access some null
pointer.

I am surprised to see the easy handle keeps previous connections alive
instead of only the latest one. Does it hold all connection history or
only a limit number?
Thanks for the help.

Daniel Stenberg <daniel-curl_at_haxx.se>
Sent by: curl-library-bounces_at_cool.haxx.se
06/08/05 02:30 AM
Please respond to
libcurl development <curl-library_at_cool.haxx.se>

To
libcurl development <curl-library_at_cool.haxx.se>
cc

Subject
Re: curl_easy_cleanup and curl-multi

On Tue, 7 Jun 2005, Zibiao.Wei_at_atxinc.com wrote:

> I am new to libcurl. My first question is how to reuse curl_easy_handle
in
> curl_multi.
>
> My test shows I have to follow these steps:
> 1. Set an url to an easy_handle.
> 2. Add the easy_handle to multi_handle.
> 3. curl_multi_perform
> 4. Remove easy_handle from multi_handle
> 5. Set another url to the easy_handle.
> 6. Add easy_handle to multi_handle again
> 7. curl_multi_perform.
>
> Am I right? Why step 4 and 6 are necessary?

As stupid as it may sound, they are necessary because that's how the multi

interface has been implmented!

Each easy handle has a state within the multi "engine" and when that state

reaches CURLM_STATE_COMPLETED, there's no other way for an app to reset it

back to CURLM_STATE_INIT unless you remove and readd the handle (as the
state
is reset on the addition).

There was once talk about allowing curl_multi_add_handle() on an already
added
handle, that would simply reset the state and thus restart that transfer.

Another option would be to add an entirely new function solely for that
purpose.

> Then I tried to download an url using an easy_handle through a
multi_handle.
> If it failed, I would change the url to another mirror server and use
the
> same easy_handle and multi_handle (remove easy, set new url, add to
multi).
> This works for me, but when I finally call curl_easy_cleanup, I got an
> error:
>
> First-chance exception at 0x0040b0f7 in ATXCommX05.exe: 0xC0000005:
Access
> violation reading location 0x00000048.

I assume this is 7.14.0 or at least a rather recent version?

Can you write up and show us the code for a complete stand-alone working
version that repeats this problem on a public URL?

If not, can you get a stack strace from the crash point and some relevant
local variable contents?

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2005-06-08