cURL / Mailing Lists / curl-library / Single Mail

curl-library

curl_multi_perform blocking for hundreds of milliseconds

From: Scott Murray <foreverpulse_at_hotmail.com>
Date: Tue, 30 Apr 2013 06:19:09 +0000

Hi, 

I'm writing a mobile application for Android that uses libcurl to make http requests for resources. I have many concurrent requests, so use the multi interface. I am using the libcurl api on my main application thread as the docs state that the multi interface is non-blocking.

I have build libcurl from git://github.com/bagder/curl.git master branch with --enable-threaded-resolver using the Android standalone toolchain method. For completeness, I have also build against openssl for https, but am not currently making requests over ssl. I am currently only making GET requests.

Everything works fine except that curl_multi_perform sometimes blocks for hundreds of milliseconds (sometimes over a thousand). This is rare, and usually it returns quickly. The multi_handle has 50 easy_handles in the multi stack, but this behaviour happens even with one easy_handle. There doesn't seem to be any obvious correlation between the number of requests and the time taken by curl_multi_perform.

Is this to be expected; have I been too optimistic in my interpretation of curl_multi_perform not blocking? Should I move all interaction with the libcurl API on to a background thread? How do people normally run a real-time application making HTTP requests with curl multi?

Thanks in advance,
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-04-30