24,860
社区成员




res = curl_easy_perform(curl);
timestamp(time_str, sizeof (time_str), FALSE);
if (CURLE_OK != res) {
// skipped many error checking lines
success = FALSE;
}
curl_slist_free_all(httpheaders);
/*
* whenever we fail, reset curl connection in the hope of
* keeping mem footprint low.
* every 5 minutes or more, reset whole curl state
*/
if (FALSE == success) {
consecutive_successes = 0;
if (do_cleanup == FALSE)
return;
time_t now;
curl_easy_cleanup(curl);
now = time(NULL);
if (last_cleanup == 0) {
last_cleanup = now;
} else if (now - last_cleanup > (5 * 60)) {
curl_global_cleanup();
if (curl_global_init(curl_glob_arg) != 0) {
fprintf(stderr, "periodic re-global-init failed\n");
exit(2);
}
}
*cu = curl_easy_init();
}
if (success && (consecutive_successes++ % 10 == 0))
printf("%s successfully reconnected to %s\n",
time_str, url);
}
库本身有问题的可能性微乎其微,还是参考一下别人是如何使用的。