cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: download thread hung in poll()

From: Alex Loukissas <alex_at_maginatics.com>
Date: Tue, 8 Nov 2011 07:54:29 -0800

> Doesn't this simply "hang" for 1000 milliseconds and then it continues?

No, it hangs for a couple minutes. My test scenario is a download of a
large number of objects, with total size of approx 15MB. One thread
(the one that's hung makes a single call to readData (with the list of
all objects), while other threads read (i.e. make calls to readData)
per object.

It appears that what causes this issue is that both threads are trying
to get the same URI at the same time and one starves the other. If I
remove a few of the URIs from the first thread, it makes some
progress, until it hits a URI that's already in the process of being
fetched by another thread.

> Why would it be bad? To me it looks perfectly legitimate. It sits there
> waiting for network traffic to arrive on the socket, file descriptor 20 in
> this specific case.
>
> If you set a progress callback for this handle, I bet you'll see it get
> called repeatedly while it waits for data to arrive.

For the hung thread, it's only called once, for the very first part of
the first object it fetches. Afterwards, it is not called until a very
long while later.

> If you wireshark the network while it poll()s you should be able to verify
> that no traffic arrives. If you still see traffic arriving, you need to
> figure out why poll() doesn't react to it. I find it unlikely that libcurl
> would pass the wrong file descriptor to the poll() call there. But of course
> until we know the actual reason for this effect I can't rule anything out
> with 100% certainty.

I will run this experiment and come back with the results.
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-11-08