cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: exception in libcurl

From: Женя <diamand_xex_at_mail.ru>
Date: Sun, 22 Mar 2015 04:43:55 +0300

 And another exception:

curl_global_init(CURL_GLOBAL_ALL);
CURLM* curl_m = curl_multi_init();
curl_multi_setopt(curl_m, CURLMOPT_MAX_TOTAL_CONNECTIONS , long(100));
curl_multi_setopt(curl_m, CURLMOPT_MAXCONNECTS, long(100));

CURLSH* curl_sh = curl_share_init();
std::vector<CURL*> h;
h.resize(600);
while(1)
{
for(int i=0; i<600; i++)
{
   h[i] = curl_easy_init();
   curl_easy_setopt(h[i], CURLOPT_URL, "primorye.ru");
   curl_easy_setopt(h[i], CURLOPT_SHARE, curl_sh);
   CURLMcode c = curl_multi_add_handle(curl_m, h[i]);
}
int running_handles;
curl_multi_perform(curl_m, &running_handles);
for(int i=600-1; i>0; i--)
{
   CURLMcode c = curl_multi_remove_handle(curl_m, h[i]);
   curl_easy_cleanup(h[i]);
}
printf("+");
}

Воскресенье, 22 марта 2015, 3:17 +03:00 от Женя <diamand_xex_at_mail.ru>:
>Hello.
>When I running next stress test, lib curl throws an exception from curl_multi_perform(). Is this known issue or something wrong with my code? 
>
>Thanks, Evgeniy
>
>
>static void perf_curl(CURLM* curl_m)
>{
>   int running_handles;
>   curl_multi_perform(curl_m, &running_handles);
>   int msgs_in_queue;
>   CURLMsg *msg = curl_multi_info_read(curl_m, &msgs_in_queue);
>   while (msg)
>   {
>      if (msg->msg == CURLMSG_DONE)
>     {
>        curl_multi_remove_handle(curl_m, msg->easy_handle);
>     }
>     msg = curl_multi_info_read(curl_m, &msgs_in_queue);
>   }
>
>}
>static size_t write_data_callback(char *buffer, size_t size, size_t nitems, void *userp)
>{
>   return size*nitems;
>}
>static size_t write_header_callback(char *buffer, size_t size, size_t nitems, void *userp)
>{
>   return size*nitems;
>}
>void test_curl()
>{
>curl_global_init(CURL_GLOBAL_ALL);
>CURLM* curl_m = curl_multi_init();
>curl_multi_setopt(curl_m, CURLMOPT_MAX_TOTAL_CONNECTIONS , long(100));
>curl_multi_setopt(curl_m, CURLMOPT_MAXCONNECTS, long(100));
>
>CURLSH* curl_sh = curl_share_init();
>std::vector<CURL*> h;
>h.resize(600);
>
>for(int i=0; i<600; i++)
>{
>      h[i] = curl_easy_init();
>      curl_easy_setopt(h[i], CURLOPT_WRITEDATA, 0L);
>      curl_easy_setopt(h[i], CURLOPT_WRITEFUNCTION, write_data_callback);
>      curl_easy_setopt(h[i], CURLOPT_HEADERDATA, 0L);
>      curl_easy_setopt(h[i], CURLOPT_HEADERFUNCTION, write_header_callback);
>      curl_easy_setopt(h[i], CURLOPT_URL, "primorye.ru");
>      curl_easy_setopt(h[i], CURLOPT_SHARE, curl_sh);
>      curl_multi_add_handle(curl_m, h[i]);
>      Sleep(10);
>   }
>   perf_curl(curl_m);
>   Sleep(50);
>   for(int i=600-1; i>0; i--)
>   {
>      curl_multi_remove_handle(curl_m, h[i]);
>      curl_easy_cleanup(h[i]);
>      perf_curl(curl_m);
>      Sleep(3);
>   }
>}

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