From 314c4bb21d9d18baf2b050bd28a1d7f6005c0723 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Fri, 4 Apr 2008 15:54:08 +0300 Subject: [PATCH] Init curl_multi once and use it until deinit --- src/map-download.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/map-download.c b/src/map-download.c index 44ded6c..60913f5 100644 --- a/src/map-download.c +++ b/src/map-download.c @@ -201,11 +201,6 @@ while (num_transfers < (4*4) && g_tree_nnodes(pui_tree)) { curl_easy_setopt(curl_easy, CURLOPT_URL, pui->src_str); curl_easy_setopt(curl_easy, CURLOPT_WRITEDATA, f); g_hash_table_insert(pui_by_easy, curl_easy, pui); - if (!_curl_multi) { - /* Initialize CURL. */ - _curl_multi = curl_multi_init(); - /*curl_multi_setopt(_curl_multi, CURLMOPT_PIPELINING, 1); */ - } curl_multi_add_handle(_curl_multi, curl_easy); num_transfers++; } else { @@ -237,9 +232,6 @@ if (!(num_transfers || g_tree_nnodes(pui_tree))) { while ((curr = g_queue_pop_tail(curl_easy_queue))) curl_easy_cleanup(curr); - curl_multi_cleanup(_curl_multi); - _curl_multi = NULL; - _curl_sid = 0; return FALSE; } @@ -501,6 +493,8 @@ curl_easy_queue = g_queue_new(); pui_tree = g_tree_new_full((GCompareDataFunc)download_comparefunc, NULL, (GDestroyNotify) progress_update_info_free, NULL); downloading_tree = g_tree_new_full((GCompareDataFunc)download_comparefunc, NULL, (GDestroyNotify) progress_update_info_free, NULL); pui_by_easy = g_hash_table_new(g_direct_hash, g_direct_equal); +_curl_multi = curl_multi_init(); +/* curl_multi_setopt(_curl_multi, CURLMOPT_PIPELINING, 1); */ } gboolean @@ -532,8 +526,6 @@ if (_curl_multi) { g_debug("Stopping downloads"); while ((curr = g_queue_pop_tail(curl_easy_queue))) curl_easy_cleanup(curr); - curl_multi_cleanup(_curl_multi); - _curl_multi = NULL; return TRUE; } g_debug("No downloads to stop"); @@ -566,6 +558,8 @@ if (_curl_multi) { g_hash_table_destroy(pui_by_easy); if (curl_easy_queue) g_queue_free(curl_easy_queue); + curl_multi_cleanup(_curl_multi); + _curl_multi = NULL; } if (_curl_sid) { -- 2.39.5