curl-library
Recovering from dropped connections with multi curl
Date: Tue, 14 Mar 2017 15:33:08 +0000
I am using multi curl to fetch a series of urls. This is following the
10-at-a-time prototype example.
The problem I am having is with dropped internet connections when this
function is already running. In such situations I would like U = 0 so
that the main loop ends and the function returns back to its origin.
This isn't happening. Most of the time after the internet connection is
dropped and then re-established, the function is stuck in the main while
loop with U != 0.
I've tried playing around with the function, commenting out and
debugging but I would appreciate any suggestions.
while(U)
{
curl_multi_perform(curl_handle, &U);
fprintf(mwp->wp->outputlog_fp, "main loop\n");
while ((msg = curl_multi_info_read(curl_handle, &Q)))
{
if (msg->msg == CURLMSG_DONE)
{
fprintf(mwp->wp->outputlog_fp, "msg done\n");
if (msg->data.result == CURLE_COULDNT_CONNECT ||
msg->data.result == CURLE_OPERATION_TIMEDOUT ||
msg->data.result == CURLE_COULDNT_RESOLVE_HOST)
{
fprintf(mwp->wp->outputlog_fp, "no connection\n");
U = 0;
}
}
/*
if (msg->msg == CURLE_COULDNT_CONNECT ||
msg->msg == CURLE_OPERATION_TIMEDOUT ||
msg->msg == CURLE_COULDNT_RESOLVE_HOST)
{
fprintf(mwp->wp->outputlog_fp, "no connection\n");
U = 0;
}
*/
else
{
fprintf(mwp->wp->outputlog_fp, "E: CURLMsg (%d)\n", msg->msg);
//U = 0;
}
char *url;
CURL *e = msg->easy_handle;
curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE, &url);
fprintf(mwp->wp->outputlog_fp, "R: %d - %s <%s>\n",
msg->data.result, curl_easy_strerror(msg->data.result), url);
curl_multi_remove_handle(curl_handle, e);
curl_easy_cleanup(e);
}
}
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2017-03-14