cURL / Mailing Lists / curl-library / Single Mail

curl-library

download thread hung in poll()

From: Alex Loukissas <alex_at_maginatics.com>
Date: Wed, 2 Nov 2011 16:21:40 -0700

Hi everyone,

I'm having an issue similar to
http://curl.haxx.se/mail/lib-2008-09/0171.html, with a twist. Short
description:

- Multi-threaded C++ application, with a readData() function that may
be called from multiple threads.
- The readData function does (in pseudocode) the following:
    CURL* handle = get a handle from a pool of handles, already initialized
    multiple calls to curl_easy_setopt() -- common options for all URLs
    loop through a list of URLs and call curl_easy_setopt
(URL-specific options) curl_easy_perform

- One thread makes a call to readData with a long list of URLs (this
is the one that's stuck). It only makes a single call to the write
function and the second (and any subsequent) call is blocked:

(gdb) bt
#0 0x0000000000821933 in poll ()
#1 0x000000000055d286 in Curl_socket_ready ()
#2 0x0000000000578e6e in Curl_do_perform ()
#3 0x000000000047517b in readData (...)
....

- Other threads make subsequent calls to readData, all of which return
successfully.

** The above behavior only happens when downloading from a remote
server (i.e. over WAN). If the same experiment is done with a local
server (e.g. on the same machine), none of the above is seen.

Once no other threads make calls to readData, the first thread
eventually wakes up and continues

It appears that I may need to guard the above pseudocode block with
lock. Of course, this would block either the first thread or the
subsequent ones, so some refactoring will be needed.

My question is: would this issue be locking-related?

Thanks
Alex
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-11-03