diff --git a/src/link.c b/src/link.c index 173a15d..ec5e707 100644 --- a/src/link.c +++ b/src/link.c @@ -341,11 +341,23 @@ static void HTML_to_LinkTable(GumboNode * node, LinkTable * linktbl) void Link_set_file_stat(Link * this_link, CURL * curl) { long http_resp; - curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_resp); + CURLcode ret = + curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_resp); + if (ret) { + lprintf(error, "%s", curl_easy_strerror(ret)); + } if (http_resp == HTTP_OK) { double cl = 0; - curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &cl); - curl_easy_getinfo(curl, CURLINFO_FILETIME, &(this_link->time)); + ret = + curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &cl); + if (ret) { + lprintf(error, "%s", curl_easy_strerror(ret)); + } + ret = + curl_easy_getinfo(curl, CURLINFO_FILETIME, &(this_link->time)); + if (ret) { + lprintf(error, "%s", curl_easy_strerror(ret)); + } if (cl <= 0) { this_link->type = LINK_INVALID; } else { @@ -774,7 +786,11 @@ TransferStruct Link_download_full(Link * link) long http_resp = 0; do { transfer_blocking(curl); - curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_resp); + CURLcode ret = + curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_resp); + if (ret) { + lprintf(error, "%s", curl_easy_strerror(ret)); + } if (HTTP_temp_failure(http_resp)) { lprintf(warning, "URL: %s, HTTP %ld, retrying later.\n", @@ -790,14 +806,17 @@ TransferStruct Link_download_full(Link * link) } while (HTTP_temp_failure(http_resp)); - curl_easy_getinfo(curl, CURLINFO_FILETIME, &(link->time)); + CURLcode ret = + curl_easy_getinfo(curl, CURLINFO_FILETIME, &(link->time)); + if (ret) { + lprintf(error, "%s", curl_easy_strerror(ret)); + } curl_easy_cleanup(curl); return ts; } long -Link_download(Link *link, char *output_buf, size_t req_size, - off_t offset) +Link_download(Link * link, char *output_buf, size_t req_size, off_t offset) { if (!link) { lprintf(fatal, "Invalid supplied\n"); @@ -840,7 +859,11 @@ range requests\n"); FREE(header.data); long http_resp; - curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_resp); + CURLcode ret = + curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_resp); + if (ret) { + lprintf(error, "%s", curl_easy_strerror(ret)); + } if (!((http_resp != HTTP_OK) || (http_resp != HTTP_PARTIAL_CONTENT) || (http_resp != HTTP_RANGE_NOT_SATISFIABLE))) { @@ -851,7 +874,10 @@ range requests\n"); } curl_off_t recv; - curl_easy_getinfo(curl, CURLINFO_SIZE_DOWNLOAD_T, &recv); + ret = curl_easy_getinfo(curl, CURLINFO_SIZE_DOWNLOAD_T, &recv); + if (ret) { + lprintf(error, "%s", curl_easy_strerror(ret)); + } /* The extra 1 byte is probably for '\0' */ if (recv - 1 == (long int) req_size) { diff --git a/src/link.h b/src/link.h index 834e080..1773af8 100644 --- a/src/link.h +++ b/src/link.h @@ -119,7 +119,8 @@ long path_download(const char *path, char *output_buf, size_t size, * \brief Download a Link * \return the number of bytes downloaded */ -long Link_download(Link *link, char *output_buf, size_t req_size, off_t offset); +long Link_download(Link * link, char *output_buf, size_t req_size, + off_t offset); /** * \brief find the link associated with a path diff --git a/src/network.c b/src/network.c index 28cef5f..c2090a3 100644 --- a/src/network.c +++ b/src/network.c @@ -120,17 +120,27 @@ curl_process_msgs(CURLMsg * curl_msg, int n_running_curl, int n_mesgs) if (curl_msg->msg == CURLMSG_DONE) { TransferStruct *ts; CURL *curl = curl_msg->easy_handle; - curl_easy_getinfo(curl_msg->easy_handle, CURLINFO_PRIVATE, - &ts); + CURLcode ret = + curl_easy_getinfo(curl_msg->easy_handle, CURLINFO_PRIVATE, + &ts); + if (ret) { + lprintf(error, "%s", curl_easy_strerror(ret)); + } ts->transferring = 0; char *url = NULL; - curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &url); + ret = curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &url); + if (ret) { + lprintf(error, "%s", curl_easy_strerror(ret)); + } /* * Wait for 5 seconds if we get HTTP 429 */ long http_resp = 0; - curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_resp); + ret = curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_resp); + if (ret) { + lprintf(error, "%s", curl_easy_strerror(ret)); + } if (HTTP_temp_failure(http_resp)) { if (!slept) { lprintf(warning, @@ -306,10 +316,13 @@ void NetworkSystem_init(void) crypto_lock_init(); } -void transfer_blocking(CURL *curl) +void transfer_blocking(CURL * curl) { TransferStruct *ts; - curl_easy_getinfo(curl, CURLINFO_PRIVATE, &ts); + CURLcode ret = curl_easy_getinfo(curl, CURLINFO_PRIVATE, &ts); + if (ret) { + lprintf(error, "%s", curl_easy_strerror(ret)); + } lprintf(network_lock_debug, "thread %x: locking transfer_lock;\n", pthread_self()); @@ -334,7 +347,7 @@ void transfer_blocking(CURL *curl) // } -void transfer_nonblocking(CURL *curl) +void transfer_nonblocking(CURL * curl) { lprintf(network_lock_debug, "thread %x: locking transfer_lock;\n", pthread_self()); diff --git a/src/util.c b/src/util.c index 231dcce..2acb11f 100644 --- a/src/util.c +++ b/src/util.c @@ -58,8 +58,7 @@ void PTHREAD_MUTEX_UNLOCK(pthread_mutex_t * x) i = pthread_mutex_unlock(x); if (i) { lprintf(fatal, - "thread %x: %d, %s\n", - pthread_self(), i, strerror(i)); + "thread %x: %d, %s\n", pthread_self(), i, strerror(i)); } } @@ -69,8 +68,7 @@ void PTHREAD_MUTEX_LOCK(pthread_mutex_t * x) i = pthread_mutex_lock(x); if (i) { lprintf(fatal, - "thread %x: %d, %s\n", - pthread_self(), i, strerror(i)); + "thread %x: %d, %s\n", pthread_self(), i, strerror(i)); } }