cURL / Mailing Lists / curl-library / Single Mail


Problems with curl 7.10.1 and the multi interface

From: Fabrizio Ammollo <>
Date: Thu, 17 Oct 2002 15:49:48 +0200


a couple of weeks ago I wrote about some experiments I was doing with the
multi interface of libcurl ; today, I have been experimenting again with it
and I'm experiencing some strange behaviour, using the same test program I
already made (which is attached to the message - forgive me for its rawness,
but I made it only to make a quick test :-) )

Mainly, I have two problems:

1) If I try to connect to my own web server, which is not active, or to any
other closed port, instead of failing because of "connection refused", my
program hangs forever on the select system call.

By calling strace on my process, I see the following:

here we are before curl_multi_perform:

fcntl(4, F_GETFL) = 0x2 (flags O_RDWR)
fcntl(4, F_SETFL, O_RDWR|O_NONBLOCK) = 0
connect(4, {sin_family=AF_INET, sin_port=htons(80),
sin_addr=inet_addr("")}}, 16) = -1 EINPROGRESS (Operation now in
select(5, NULL, [4], [4], {0, 0}) = 1 (out [4], left {0, 0})
getsockopt(4, SOL_SOCKET, SO_ERROR, [111], [4]) = 0
gettimeofday({1034858499, 526859}, NULL) = 0
select(5, NULL, [4], [4], {0, 0}) = 0 (Timeout)

here we are after curl_multi_perform, where my own select is called:

select(5, [], [4], [], NULL

It seems to me that the descriptors are correctly set (4 is set for writing
because it's a connection in progress) so why is this happening ?

2) I tried connecting, as a test, to, and I have seen that
if I don't specify the option to follow HTTP redirects the transfer is
considered finished but the file is empty. This is fine.
But, if I specify to follow the redirects, the execution of the program
continues until the max fd set by curl_multi_fdset is -1, and then
(obviously) hangs.

From strace, I see the following:

recv(5, "HTTP/1.1 302 Found\r\nDate: Thu, 17 Oct 2002 13:01:43 GMT\r\nServer:
Apache/1.3.27 (Unix) mod_gzip/ PHP/4.2.3\r\nX-Powered-By:
PHP/4.2.3\r\nX-Accelerated-By: PHPA/1.3.3\r\nLocation:\r\nConnection: close\r\nTransfer-Encoding:
chunked\r\nContent-Type: text/html\r\n\r\n0\r\n\r\n", 20479, 0) = 283

which is called by curl_multi_perform, and then, after my program calls

select(0, [], [], [], NULL

Then, I have one doubt, too: is it correct for libcurl to "wake up" so much my
program even if no data is really transferred ? I mean, during the program
execution I make a lot of debugging prints, and I see the following many

prev_running/still_running: [1/1]
started/still running connections: [1/1]
highest fd set by curl_multi_fdset: [4]
data is available !
curl_multi_perform called 1 times

but if I check this with the output of strace, I see this:

write(1, "prev_running/still_running: [1/1]\n", 34) = 34
write(1, "started/still running connections: [1/1]\n", 41) = 41
write(1, "highest fd set by curl_multi_fdset: [5]\n", 40) = 40
select(6, [5], [5], [], NULL) = 1 (out [5])
write(1, "data is available !\n", 20) = 20
gettimeofday({1034860278, 190493}, NULL) = 0
gettimeofday({1034860278, 190596}, NULL) = 0
write(1, "curl_multi_perform called 1 times\n", 34) = 34

I think the reason is that the socket is checked for writing even if this
could not be really needed.. am I right ? I think it is not a good thing,
because the applications are called too many times for no valid reason.

Another doubt, not really related to libcurl, is the following: is there a
known reason why I am not able to strace the execution of my program when
using https ?

Thank you in advance as usual.


This email is sponsored by: viaVerio will pay you up to
$1,000 for every account that you consolidate with us.;4749864;7604308;v?

Received on 2002-10-17