LibcURL execution function not called

the cURL / OS version in question is 7.15 and Red Hat 5, they are installed on the stone, although they cannot change them.

The actual execution function, which is not called at all

int CurlUtil::progressCallback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow) { DEFN_METHOD_NAME( "progressCallback" ); EX_ENTRY_EXIT(); EX_DEBUG("Total downloaded " << dlnow << "/" << dltotal); EX_DEBUG("Total uploaded " << ulnow << "/" << ultotal); CurlUtil* curlUtil = (CurlUtil*)clientp; // If you return anything but 0, curl will abort transfer return (true == curlUtil->killed()) ? 1 : 0; } 

Installation Code:

 curl_easy_setopt(m_curl, CURLOPT_NOPROGRESS, 0); curl_easy_setopt(m_curl, CURLOPT_PROGRESSFUNCTION, CurlUtil::progressCallback); curl_easy_setopt(m_curl, CURLOPT_PROGRESSDATA, this) 

Where CurlUtil is the class in which the code exists. CURLOPT_DEBUGFUNCTION works fine and is configured with exactly the same function.

+5
source share
1 answer

the problem is calling the callback function call. For gcc compilers, it needs the __cdecl or / Gd option. Check the compiler options if the function is already static. C ++ member functions are called using thiscall calls. Take a look at the following link, it provided a cleaner way if you want to have a class that is responsible for handling transfer status and statistics: How can I use a member function pointer in libcurl

PS: My editing was slower as I cross-checked. Therefore publication as an answer.

+1
source

Source: https://habr.com/ru/post/1207624/


All Articles