cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Recommended architecture for streaming over multiple sockets

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 9 Mar 2016 23:31:11 +0100 (CET)

On Wed, 9 Mar 2016, Boutin Maël wrote:

> Ok for curl_multi_info_read. I changed my code as follow :
>
> curlret = curl_multi_perform(m_pstCurlMultiHandle, &iRunningFDs);
> if (!iRunningFDs)
> {
> usleep(10000);
> }

Why do you sleep when there's no more transfers running?

> /* wait for activity, timeout or "nothing" */
> curlret = curl_multi_wait(m_pstCurlMultiHandle, NULL, 0, 10000,
> &iWaitFDs);
> if (iWaitFDs)
> {
> struct CURLMsg *m;
> do {
> int msgq = 0;
> m = curl_multi_info_read(m_pstCurlMultiHandle, &msgq);

Why do you check the queue only when curl_multi_wait() told you there's socket
acivity? Transfers can end without that (due to timeouts etc)!

> However this does not work, as multi_wait will here "wait" for the duration.

If there's no socket activity, sure.

> I dont want this behaviour because the data to be sent are coming from
> another thread and i want to send them as soon as they are available.

Make it wait for another socket/pipe that you signal on from that other thread
when data arrives? Or perhaps if you want it simpler: make the max waiting
time fairly short and then check for data and then loop.

-- 
  / daniel.haxx.se

-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-03-09