curl-library
CURLOPT_MAX_RECV_SPEED_LARGE, curl_multi_socket and curl_multi_socket_all
Date: Wed, 11 Jun 2008 01:23:55 -0400
I'm using the curl_multi_socket interface and at the same time limiting the transfer speed with CURLOP_MAX_RECV_SPEED_LARGE and I can't get it to work correctly. From what I can tell, when the transfer rate goes above the max, I get a socket callback with the "what" parameter set to CURL_POLL_REMOVE. After that I never get another socket callback so I never pass my socket to curl_multi_socket_action and my request never completes.
I had assumed that calling curl_multi_socket_action with CURL_SOCKET_TIMEOUT would eventually give me another socket callback with the "what" parameter set to CURL_POLL_IN, CURL_POLL_OUT or CURL_POLL_IN_OUT but it never does.
The only way I can get the transfer started again is to repeatedly call curl_multi_socket_all over and over again after I get the CURL_POLL_REMOVE. While this works, I don't have any indication how long I need to wait before making the call so I end up with a busywait - calling curl_multi_socket_all in a tight loop. Is there a way to find out from libcurl how long to wait before calling curl_multi_socket_all so I can give some other parts of my system a few CPU cycles while I'm waiting.
By the way, the regular multi interface has the same problem. Once the transfer speed goes above the max, the call to curl_multi_fdset returns a maxfd of -1 at which point you can either wait for the timeout (which at this point is usually around 300 seconds) or you can call curl_multi_perform in a tight loop until the transfer speed goes back under the max.
I have attached small test program that illustrates the problem.
Thanks,
Josh
- text/plain attachment: multi_socket.cpp