cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: test 91 fails - cause found?

From: Patrick Smith <patsmith_at_pobox.com>
Date: Tue, 27 Jan 2004 10:37:37 -0500

Daniel Stenberg wrote:
>>I think the race is between the server's call to close() and libcurl's call
>>to select() in SocketIsDead in lib/url.c. If the select happens first,
>>libcurl will reuse the connection, and the test fails.
>
> Hm, assuming that this is correct, which is likely and indeed something that
> can happen this is what is *supposed* to be happening:

As I said, I didn't look at the code in much detail. So I missed that
you try to handle this case. Sorry about that.

> Curl_connect() succeeds. It (wrongly) thinks the connection is still alive to
> be used. It then proceeds to call Curl_do() to issue the request for this
> single "document".
>
> Curl_do() calls the protocol-specific "do"-function, which in the case of HTTP
> is called Curl_http(). That function is supposed to return CURLE_SEND_ERROR if
> there's something wrong in the request sending. If the connection really just
> was closed, curl should have problems sending the request and thus this is
> what should happen.
>
> I suspect that perhaps this isn't really happening.

Indeed not. The server closes the connection after the client has sent
the request. So the client's later call to recv() fails with ECONNRESET.

Here's the relevant section of the strace output for the client, from a
failed test:

10:09:01.011374 write(2, "Connection #0 left intact\n", 26) = 26
10:09:01.011573 write(2, "* ", 2) = 2
10:09:01.011734 write(2, "Issue another request to this UR"..., 62) = 62
10:09:01.011904 gettimeofday({1075216141, 11960}, NULL) = 0
10:09:01.012033 gettimeofday({1075216141, 12090}, NULL) = 0
10:09:01.012163 gettimeofday({1075216141, 12221}, NULL) = 0
10:09:01.012343 _newselect(0x4, 0x7fffedf8, 0, 0, 0x7fffee78) = 0
10:09:01.012515 write(2, "* ", 2) = 2
10:09:01.012681 write(2, "Re-using existing connection! (#"..., 35) = 35
10:09:01.012851 gettimeofday({1075216141, 12906}, NULL) = 0
10:09:01.012996 gettimeofday({1075216141, 13055}, NULL) = 0
10:09:01.013148 write(2, "* ", 2) = 2
10:09:01.013304 write(2, "Connected to (127.0.0.1) port 8"..., 36) = 36
10:09:01.013472 gettimeofday({1075216141, 13528}, NULL) = 0
10:09:01.013685 write(2, "* ", 2) = 2
10:09:01.013921 write(2, "Server auth using NTLM with user"..., 51) = 51
10:09:01.014174 send(3, "GET /91 HTTP/1.1\r\nAuthorization:"..., 286, 0)
= 286
10:09:01.014388 write(2, "> ", 2) = 2
10:09:01.014544 write(2, "GET /91 HTTP/1.1\r\nAuthorization:"..., 286) = 286
10:09:01.014718 gettimeofday({1075216141, 14775}, NULL) = 0
10:09:01.014842 gettimeofday({1075216141, 14896}, NULL) = 0
10:09:01.015044 _newselect(0x4, 0x10033870, 0x100338f0, 0, 0x7ffff700) = 1
10:09:01.017497 recv(3, 0x1002af44, 16383, 0) = -1 ECONNRESET
(Connection reset by peer)

If you want, I can put the full strace outputs for client and server up
for http. Sending 60K+ to everyone on the list seems a bit much, so I'm
not attaching them here.

By the way, even if the test normally succeeds on your system, I suspect
you can make it fail reliably by nice'ing the server.

-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
Received on 2004-01-27