From 9850be72677d8341b414f52aab31d9737ebfb6bf Mon Sep 17 00:00:00 2001 From: luddens Date: Fri, 25 Oct 2019 12:12:16 +0200 Subject: [PATCH] add Curl error message --- src/aria2.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/aria2.cpp b/src/aria2.cpp index 0cef601b7..420797aa8 100644 --- a/src/aria2.cpp +++ b/src/aria2.cpp @@ -80,16 +80,27 @@ Aria2::Aria2(): callCmd.push_back("--file-allocation=none"); mp_aria = Subprocess::run(callCmd); mp_curl = curl_easy_init(); + char errbuf[CURL_ERROR_SIZE]; curl_easy_setopt(mp_curl, CURLOPT_URL, "http://localhost/rpc"); curl_easy_setopt(mp_curl, CURLOPT_PORT, m_port); curl_easy_setopt(mp_curl, CURLOPT_POST, 1L); + curl_easy_setopt(mp_curl, CURLOPT_ERRORBUFFER, errbuf); int watchdog = 50; while(--watchdog) { sleep(10); + errbuf[0] = 0; auto res = curl_easy_perform(mp_curl); if (res == CURLE_OK) { break; + } else if (watchdog == 1) { + std::cerr <<" curl_easy_perform() failed." << std::endl; + fprintf(stderr, "\nlibcurl: (%d) ", res); + if (errbuf[0] != 0) { + std::cerr << errbuf << std::endl; + } else { + std::cerr << curl_easy_strerror(res) << std::endl; + } } } if (!watchdog) {