Skip to content

Instantly share code, notes, and snippets.

@bagder
Created September 22, 2014 11:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bagder/dd7a56d2bb76d99a12a6 to your computer and use it in GitHub Desktop.
Save bagder/dd7a56d2bb76d99a12a6 to your computer and use it in GitHub Desktop.
/* Trying to repeat bug report 1426
https://sourceforge.net/p/curl/bugs/1426/ */
#include <stdio.h>
#include <string.h>
/* somewhat unix-specific */
#include <sys/time.h>
#include <unistd.h>
/* curl stuff */
#include <curl/curl.h>
/*
* Simply download a HTTP file.
*/
int main(int argc, char **argv)
{
CURL *http_handle;
CURLM *multi_handle;
int still_running; /* keep number of running handles */
if(argc < 2) {
printf("Usage: program [URL]\n");
return 1;
}
curl_global_init(CURL_GLOBAL_DEFAULT);
http_handle = curl_easy_init();
curl_easy_setopt(http_handle, CURLOPT_URL, argv[1]);
curl_easy_setopt(http_handle, CURLOPT_LOW_SPEED_LIMIT, 1L);
curl_easy_setopt(http_handle, CURLOPT_LOW_SPEED_TIME, 2L);
curl_easy_setopt(http_handle, CURLOPT_CONNECTTIMEOUT, 2L);
/* init a multi stack */
multi_handle = curl_multi_init();
/* add the individual transfers */
curl_multi_add_handle(multi_handle, http_handle);
/* we start some action by calling perform right away */
curl_multi_perform(multi_handle, &still_running);
do {
int msgs;
CURLMsg *m;
curl_multi_perform(multi_handle, &still_running);
m = curl_multi_info_read(multi_handle, &msgs);
if(m) {
fprintf(stderr, "RETURNED %d\n", m->data.result);
break;
}
} while(still_running);
curl_multi_remove_handle(multi_handle, http_handle);
curl_easy_cleanup(http_handle);
curl_multi_cleanup(multi_handle);
curl_global_cleanup();
return 0;
}
@fritsch
Copy link

fritsch commented Sep 22, 2014

We are setting a whole lot other options additionally: https://github.com/xbmc/xbmc/blob/master/xbmc/filesystem/CurlFile.cpp#L429

The Arch user, that reported this bug was told to gather additional logfiles with more curl debugging output which can be enabled within xbmc. I hope he will add those to the original bugreport so that it gets easier to find the issue.

Thanks very much to find that regression.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment