Hello,
CURL seems to crash in my app when I rely on the TIMEOUT option. I wrote a
simple app to isolate the problem (attached).
I've tried following suggestions of other threads, to set the ERRORBUFFER
option, but that didn't seem to work either.
Any suggestions would be greatly appreciated.
Thanks,
-Roland
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <pthread.h>
#include "curl/curl.h"
#define NUM 16
size_t data(void *ptr, size_t size, size_t nmemb, void *data)
{
return nmemb;
}
void *callback(void *context)
{
CURL *curl;
printf("start\n");
curl = curl_easy_init();
if(curl)
{
curl_easy_setopt(curl, CURLOPT_USERAGENT, "Download Agent");
curl_easy_setopt(curl, CURLOPT_URL, "http://divxtrailers.divx.com/Gamer-DivXPlusHD.mkv");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, NULL);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10);
if(curl_easy_perform(curl) != 0)
{
printf("timeout\n");
}
curl_easy_cleanup(curl);
}
else
{
printf("error\n");
}
return NULL;
}
int main()
{
int i;
pthread_t thread[NUM];
for(i = 0; i < NUM; i++)
{
if(pthread_create(&thread[i], NULL, callback, NULL) != 0)
{
printf("error\n");
}
}
for(i = 0; i < NUM; i++)
{
if(pthread_join(thread[i], NULL) != 0)
{
printf("error\n");
}
}
printf("done...\n");
return 0;
}
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html