cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl_multi_remove_handle closes easy handle, causes crash

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 23 Mar 2010 13:10:57 +0100 (CET)

On Tue, 23 Mar 2010, Daniel Stenberg wrote:

>> I have attached my test program. I don't know of any public FTP servers,
>> but I have tested it with 3 different ones and the server does not seem to
>> matter. Simply change the code of the function initEasyRequest and enter
>> the login details of any FTP server and it should work (or rather, crash).
>
> Update: I can repeat the problem based on your example app, thanks a lot.
> I'm working on trying to understand it properly to make the accurate fix.
> Stay tuned!

Here's my suggested fix that makes the test program run fine for me (and all
test cases too). I intend to commit and push to the git repo within shortly.

diff --git a/lib/multi.c b/lib/multi.c
index b240212..d04fcf6 100644
--- a/lib/multi.c
+++ b/lib/multi.c
@@ -2416,10 +2416,16 @@ static CURLMcode add_closure(struct Curl_multi *multi,

      if(!inuse) {
        /* cl->easy_handle is now killable */
- infof(data, "Delayed kill of easy handle %p\n", cl->easy_handle);
+
        /* unmark it as not having a connection around that uses it anymore */
        cl->easy_handle->state.shared_conn= NULL;
- Curl_close(cl->easy_handle);
+
+ if(cl->easy_handle->state.closed) {
+ infof(data, "Delayed kill of easy handle %p\n", cl->easy_handle);
+ /* close handle only if curl_easy_cleanup() already has been called
+ for this easy handle */
+ Curl_close(cl->easy_handle);
+ }
        if(p)
          p->next = n;
        else

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2010-03-23