curl-library
error happened in curl when I check with valgrind
Date: Fri, 16 Apr 2010 17:46:50 +0800 (CST)
ERROR SUMMARY: 43789 errors from 10 contexts (suppressed: 4 from 1)
The version of curl is 7.20.0, c-ares is 1.7.1
I must use multi perform, beacuse there is a lot of web page to get. But a lot of errors happened when I checked it with valgrind. And I think , thoese errors will lead other errors , such as segmentation fault. I don't know how to solve it , please help me. Thanks you!!
my code is :
#include<iostream>
#include<string>
#include<curl/curl.h>
using namespace std;
int main()
{
curl_global_init(CURL_GLOBAL_ALL);
CURL* curl1 = curl_easy_init();
if (!curl1)
return 0;
string urll = "https://poptartssucktoasted.sslpowered.com";
curl_easy_setopt(curl1, CURLOPT_URL, urll.c_str());
curl_easy_setopt(curl1, CURLOPT_TIMEOUT, 5);
curl_easy_setopt(curl1, CURLOPT_CONNECTTIMEOUT, 5);
curl_easy_setopt(curl1, CURLOPT_VERBOSE, 0);
CURLM* curlm = curl_multi_init();
curl_multi_add_handle(curlm, curl1);
int running = 0;
while (CURLM_CALL_MULTI_PERFORM == curl_multi_perform(curlm, &running))
{
;
}
while (running)
{
timeval tv;
tv.tv_sec = 1;
tv.tv_usec = 0;
int max_fd;
fd_set fd_read;
fd_set fd_write;
fd_set fd_except;
FD_ZERO(&fd_read);
FD_ZERO(&fd_write);
FD_ZERO(&fd_except);
curl_multi_fdset(curlm, &fd_read, &fd_write, &fd_except, &max_fd);
int return_code = select(max_fd + 1, &fd_read, &fd_write, &fd_except,
&tv);
if (return_code < 0)
{
break;
}
else
{
while(CURLM_CALL_MULTI_PERFORM == curl_multi_perform(curlm,
&running))
{
;
}
}
}
curl_multi_remove_handle(curlm, curl1);
curl_easy_cleanup(curl1);
curl_multi_cleanup(curlm);
curl_global_cleanup();
return 0;
}
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-04-16