curl-library
Re: segfault in hash.c
Date: Tue, 9 Sep 2003 05:35:10 -0700 (PDT)
> This looks like a case of memory being overwritten, but it is really hard
> for me to say that this is a libcurl matter or something your application
> does by itself.
> I guess you can't repeat this problem with a much smaller and stand-alone
> plain-C program?
Could you please try this with/without ares, and let me know the results?
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <unistd.h>
#include <curl/curl.h>
char *urls[] = {
"http://images.sourceforge.net/images/blank.gif",
"http://images.sourceforge.net/images/navbar.gif",
"http://ads.osdn.com/?op=iframe&position=1&allpositions=1,2,7&site_id=2",
"http://images-aud.sourceforge.net/pc.gif?l,6940",
"http://images.sourceforge.net/images/head_bgx.gif",
"http://images.sourceforge.net/head_bg_new.gif",
"http://images.sourceforge.net/images/chrome_bar.png",
"http://images.sourceforge.net/images/menubar_bg.png",
"http://images.sourceforge.net/menubar_l.png",
"http://images.sourceforge.net/div.png",
"http://images.sourceforge.net/menubar_r.png",
"http://images.sourceforge.net/images/DB2powered.gif",
"http://images.sourceforge.net/div_grad_blue.gif",
"http://images.sourceforge.net/images/blank.gif",
"http://ads.osdn.com/?op=iframe&position=7&site_id=2",
"http://images.sourceforge.net/pix.gif",
"http://images.sourceforge.net/images/mk1.gif",
"http://images.sourceforge.net/mk2a_notour.gif",
"http://images.sourceforge.net/images/div_grad.gif",
"http://images.sourceforge.net/icon_foundry_wht.gif",
"http://images.sourceforge.net/sf.net_box.gif",
"http://ads.osdn.com/?op=iframe&position=2&site_id=2"
};
#define NUM_HANDLES sizeof(urls) / sizeof(char *)
size_t write_cb( char *buffer, size_t size,
size_t nitems, void *writedata ) {
printf("%s (%d bytes)\n", (char *)writedata, size*nitems);
return size*nitems;
}
int main(void) {
CURL* curls[NUM_HANDLES];
CURLM* multi;
int still_running;
int i;
multi = curl_multi_init();
for ( i=0; i < NUM_HANDLES; i++ ) {
curls[i]=curl_easy_init();
curl_easy_setopt(curls[i], CURLOPT_URL, urls[i]);
curl_easy_setopt(curls[i], CURLOPT_CONNECTTIMEOUT, 30);
curl_easy_setopt(curls[i], CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt(curls[i], CURLOPT_WRITEFUNCTION, write_cb);
curl_easy_setopt(curls[i], CURLOPT_WRITEDATA, (void *)urls[i]);
curl_multi_add_handle(multi, curls[i]);
}
while ( CURLM_CALL_MULTI_PERFORM ==
curl_multi_perform(multi, &still_running) );
while (still_running) {
struct timeval timeout;
int rc;
fd_set fdread;
fd_set fdwrite;
fd_set fdexcep;
int maxfd;
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
timeout.tv_sec = 1;
timeout.tv_usec = 0;
curl_multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd);
rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
switch(rc) {
case -1:
break;
case 0:
default:
while ( CURLM_CALL_MULTI_PERFORM ==
curl_multi_perform(multi, &still_running) );
break;
}
}
curl_multi_cleanup(multi);
for ( i=0; i < NUM_HANDLES; i++ ) curl_easy_cleanup(curls[i]);
return 0;
}
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2003-09-09