cURL / Mailing Lists / curl-library / Single Mail

curl-library

Crash in curl_easy_cleanup

From: Braden McDaniel <braden_at_endoframe.com>
Date: Sun, 31 Dec 2006 19:55:34 -0500

I have the following loop to see what transfers are complete:

        while ((msg = curl_multi_info_read(curl_source->multi_handle,
                                           &msgs_in_queue))) {
            if (msg->msg == CURLMSG_DONE) {
                curl_multi_remove_handle(curl_source->multi_handle,
                                         msg->easy_handle);
                const stream_data_map_t::size_type num_erased =
                    callback_data->stream_data_map.erase(msg->easy_handle);
                g_assert(num_erased == 1);
                g_assert(curl_source->outstanding_handles > 0);
                --curl_source->outstanding_handles;
                std::ostringstream command;
                command << "destroy-stream " << ptrdiff_t(msg->easy_handle) << '\n';
                const ssize_t bytes_written = ::write_command(command.str());
                g_return_val_if_fail(
                    bytes_written == ssize_t(command.str().length()),
                    false);
                curl_easy_cleanup(msg->easy_handle);
            }
        }

I get a crash in response to the call to curl_easy_cleanup at the end of
the loop. Clearly I'm Doing It Wrong; however, the Right way to do this
isn't clear to me. The documentation indicates that the easy handle is
usable on its own after being removed from the multi handle; so
presumably I need to call curl_easy_cleanup on it (right?). But if it's
not safe to do that at this point, when is it safe to do?

-- 
Braden McDaniel                           e-mail: <braden_at_endoframe.com>
<http://endoframe.com>                    Jabber: <braden@jabber.org>
Received on 2007-01-01